[Cython] [cython-users] cleaning up in a module

Stefan Behnel stefan_ml at behnel.de
Wed Feb 29 15:41:29 CET 2012


Stefan Behnel, 29.02.2012 14:42:
> Stefan Behnel, 29.02.2012 14:34:
>> Henry Gomersall, 29.02.2012 14:30:
>>> What's the preferred way to clean up a C library when a module is
>>> deleted?
>>
>> PEP 3121:
>>
>> http://www.python.org/dev/peps/pep-3121/
>>
>> However, given that CPython doesn't currently support unloading extension
>> modules, your question is rather hypothetical.
> 
> Oh, what you *can* do, however, is register an "atexit" function that does
> the cleanup when the interpreter terminates.

Speaking of which, what about allowing users to implement a function

cdef void __dealloc__()

at the module level, which would then be called by the module cleanup
function (if generated) before running the rest of the cleanup code?

That would allow for an easier transition of user code towards a better
support of PEP 3121, specifically m_clear().

http://trac.cython.org/cython_trac/ticket/218

Stefan


More information about the cython-devel mailing list