Speeding up Python's exit

Chris Angelico rosuav at gmail.com
Thu Feb 28 18:33:44 CET 2013

On Fri, Mar 1, 2013 at 4:31 AM, Devin Jeanpierre <jeanpierreda at gmail.com> wrote:
> On Thu, Feb 28, 2013 at 12:06 PM, Chris Angelico <rosuav at gmail.com> wrote:
>> Is it any different if you create a deliberate reference loop and then
>> stuff it into some module somewhere? That would force it to be kept
>> until interpreter shutdown, and then a cyclic garbage collection after
>> that, which quite probably would be never run. A stupid trick,
>> perhaps, but it might work; I tested it with a dummy class with a
>> __del__ method and it wasn't called. Putting it into some other module
>> may not be necessary, but I don't know what happens with the
>> interactive interpreter and what gets freed up when.
> __del__ is never called for cyclic references.

D'oh. Test is flawed, then. But is the theory plausible? That the
cycle detector won't be called on exit after other modules get freed?


More information about the Python-list mailing list