Numpy C-Api example gives a SegFault

后端 未结 1 1977
心在旅途
心在旅途 2020-12-16 20:55

I\'m trying to understand how the Python C- Api works, and I want to exchange numpy arrays between Python and a C Extension.

So, I started this tutorial: http://dsnr

相关标签:
1条回答
  • 2020-12-16 21:39

    Your init function for the module needs to call

    import_array();
    

    after

    (void) Py_InitModule("trace", TraceMethods);
    

    It mentions this in the tutorial near the top, but it is easy to miss. Without this, it segfaults on PyArray_ContiguousFromObject.

    0 讨论(0)
提交回复
热议问题