dealloc function in python extend c module
Philip Semanchuk
philip at semanchuk.com
Thu Jul 2 23:17:35 EDT 2009
On Jul 2, 2009, at 9:28 PM, Gabriel Genellina wrote:
> En Thu, 02 Jul 2009 14:22:53 -0300, Philip Semanchuk
> <philip at semanchuk.com> escribió:
>>
>> Hi Shen,
>> I'm no expert on Python memory management, but since no once else
>> has answered your question I'll tell you what I *think* is happening.
>>
>> Python doesn't delete objects as soon as they're dereferenced.
>
> Nope. CPython *does* destroy objects as soon as their reference count
> reaches zero. It does not rely on garbage collection for that.
>
>> It merely marks them as safe for garbage collection (GC). If GC
>> never happens (and it might not in a small test program), your
>> dealloc function won't run.
>
> The garbage collector is only used to recover memory from object
> cycles
> (in the CPython implementation; Jython *does* use garbage collection
> for
> "normal" object destruction too)
>
>> Now some more knowledgeable person will probably correct me. =)
Wow, that last part was the only part I got right. =) Thanks for
straightening me out, Gabriel.
More information about the Python-list
mailing list