[C++-sig] Reference count on class object and import()

Jim Bosch talljimbo at gmail.com
Tue Nov 2 19:34:14 CET 2010


On 11/02/2010 11:04 AM, Simon W wrote:
> Alright, it was a couple of days ago since I last had a look on this and
> it turns out that issue described in my first mail still persists.
> Although I had a typo. Swap 4 with 3 on the reference count. Also, when
> Im using PyImport_Import() directly it also shows 2 reference counts?
>

Python stores a global list of loaded modules, as a cache to speed up 
future imports.  You can look them up in sys.modules, though I don't 
think trying to delete things from that list is allowed.  To my 
knowledge, there is no way to unload a Python module, though one can of 
course force a reload.

Jim


More information about the Cplusplus-sig mailing list