Where & how to deallocate resources in Python C extension

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Feb 3 12:16:30 EST 2009

En Mon, 02 Feb 2009 21:03:18 -0200, <fredbasset1000 at gmail.com> escribió:

> I've written a C extension, see code below, to provide a Python
> interface to a hardware watchdog timer.  As part of the initialization
> it makes some calls to mmap, I am wondering should I be making
> balanced calls to munmap in some kind of de-init function?  Do Python
> extensions have d'tors?

No, there is no way to de-initialize an extension module. That's a big  
In some cases you may provide your own function (and hope the users call  
it when needed), or use Py_AtExit.

Gabriel Genellina

More information about the Python-list mailing list