memoryview handling deallocated memory

djd at debrunners.com djd at debrunners.com
Wed Jun 28 15:41:04 EDT 2017


>From C I'm creating a memoryview object that wraps memory that is not under my control and will be deallocated when the C function creating the memoryview and passing it into Python returns.

In Python 3.5 I can invoke `memoryview.release()` to handle this situation but I'm not seeing any equivalent in Python 2.7 (and I need to support both environments).

Is there some alternate approach for Python 2.7? I've thought about accessing the Py_buffer and updating it to have zero length and NULL pointer, but that doesn't feel right.

TIA.



More information about the Python-list mailing list