pub static PY_ARRAY_API: PyArrayAPI
Expand description

A global variable which stores a ‘capsule’ pointer to Numpy Array API.

You can access raw C APIs via this variable.

See PyArrayAPI for what methods you can use via this variable.

Example

use numpy::{PyArray, npyffi::types::NPY_SORTKIND, PY_ARRAY_API};
pyo3::Python::with_gil(|py| {
    let array = PyArray::from_slice(py, &[3, 2, 4]);
    unsafe {
        PY_ARRAY_API.PyArray_Sort(py, array.as_array_ptr(), 0, NPY_SORTKIND::NPY_QUICKSORT);
    }
    assert_eq!(array.readonly().as_slice().unwrap(), &[2, 3, 4]);
})