numcodecs-python 0.7.1

pyo3 bindings to the numcodecs API for buffer compression
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use numpy::PyUntypedArray;
use pyo3::{prelude::*, sync::PyOnceLock};

pub fn numpy_asarray<'py>(
    py: Python<'py>,
    a: Borrowed<'_, 'py, PyAny>,
) -> Result<Bound<'py, PyUntypedArray>, PyErr> {
    static AS_ARRAY: PyOnceLock<Py<PyAny>> = PyOnceLock::new();

    let as_array = AS_ARRAY.import(py, "numpy", "asarray")?;

    as_array.call1((a,))?.extract()
}