[Python-Dev] Marking GC details as CPython-only (original) (raw)
Maciej Fijalkowski fijall at gmail.com
Wed Feb 13 20:22:14 CET 2013
- Previous message: [Python-Dev] Marking GC details as CPython-only
- Next message: [Python-Dev] Marking GC details as CPython-only
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Feb 13, 2013 at 9:09 PM, Xavier Morel <python-dev at masklinn.net> wrote:
On 2013-02-13, at 19:48 , Maciej Fijalkowski wrote:
Hi
I've tried (and failed) to find what GC details (especially finalizer semantics) are CPython only and which ones are not. The best I could find was the documentation of del here: http://docs.python.org/2/reference/datamodel.html Things were pypy differs: * finalizers in pypy will be called only once, even if the object is resurrected. I'm not sure if this is detail or we're just plain incompatible. * pypy breaks cycles and runs finalizers in random order (but topologically correct), hence gc.garbage is always empty. I think this part is really just an implementation detail * we're discussing right now about running multiple finalizers. We want to run them in order, but if there is a link a -> b and a becomes unreachable, we want to reserve the right to call finalizer a then finalizer b, even if a.del resurrects a. What do you think? Overall, the del is baaad. Cheers, fijal There may be one more, although I'm not sure whether it's a GC artifact or something completely unspecified: if a context manager is part of a suspended stack (because it's in a generator) when the program terminates, cpython will run exit but pypy will not -- # -- encoding: utf-8 -- class C(object): def enter(self): print ("entering") def exit(self, *args): print ("exiting") def gen(): with C(): yield r = gen() next(r) -- $ python2 test.py entering exiting $ python3 test.py entering exiting $ pypy test.py entering $ --
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fijall%40gmail.com
I think it's well documented you should not rely on stuff like that being run at the exit of the interpreter. I think we'll try harder to run finalizers at the end of the interpreter (right now we only flush files). File the issue.
- Previous message: [Python-Dev] Marking GC details as CPython-only
- Next message: [Python-Dev] Marking GC details as CPython-only
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]