这是这个问题的后续行动.
(为什么/何时)是否更适合Py_ssize_t用于索引?在我刚发现的文档中
Run Code Online (Sandbox Code Playgroud)# Purists could use "Py_ssize_t" which is the proper Python type for # array indices.
- >这是否始终指的是索引NumPy/Cython - 数组/ - 应该使用的视图Py_ssize_t?
- >是Py_ssize_t例如一个unsigned int,这样我可以不使用@cython.boundscheck(False)
我正在阅读Python C扩展中的内存管理文档,据我所知,似乎没有太多理由使用malloc而不是PyMem_Malloc.假设我想分配一个不暴露给Python源代码的数组,并将存储在一个将被垃圾收集的对象中.有什么理由可以使用malloc吗?