Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从 C 扩展中切入一维 NumPy。我在 C API 中看到了各种用于创建新数组、重塑、索引特定值等的辅助函数。但我没有看到像 PyArray_Slice1D(array, start, stop, step) 这样的东西。这样的事情存在吗?
您可以使用 Python API:创建切片对象PySlice_New(),然后调用PyObject_GetItem():
PySlice_New()
PyObject_GetItem()
PyObject* PySlice_New(PyObject *start, PyObject *stop, PyObject *step) PyObject* PyObject_GetItem(PyObject *o, PyObject *key)