Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Stefan Richthofer
Your test program performs no resurrection of x. Interestingly, it does not change behavior if you write class X(object): def __del__(self): X.x = self print ref() (Thanks for making me aware of this! My test-case was already initially the more complex one given below) But

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Antoine Pitrou
On Mon, 27 Oct 2014 14:36:31 +0100 Stefan Richthofer stefan.richtho...@gmx.de wrote: Your test program performs no resurrection of x. Interestingly, it does not change behavior if you write class X(object): def __del__(self): X.x = self print ref() (Thanks for

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Stefan Richthofer
It's not that resurrection occurs indirectly, it's that the object pointed to by x2 always remains alive Yes, this is right for CPython, more precisely this is about the definition of the word resurrection (in language-independent sense), which seems not to be unique. I already pointed out One

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Antoine Pitrou
On Mon, 27 Oct 2014 16:20:06 +0100 Stefan Richthofer stefan.richtho...@gmx.de wrote: I already pointed out One can surely argue x2 has never been dead, or see it as it was killed along with x and then resurrected by x. In Java and thus in Jython, it is treated as the second one. You mean

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Stefan Richthofer
You mean Jython deletes instance attributes before calling __del__ ? No. I think the term of object resurrection usually does not mean bringing back a deleted object in the sense that memory was already freed. I think it rather means that nothing referred to an object, so it was on the

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Antoine Pitrou
On Mon, 27 Oct 2014 17:23:23 +0100 Stefan Richthofer stefan.richtho...@gmx.de wrote: You mean Jython deletes instance attributes before calling __del__ ? No. I think the term of object resurrection usually does not mean bringing back a deleted object in the sense that memory was already

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Stefan Richthofer
I already admitted that it is implementation specific whether one would talk of resurrection, even in one and the same scenario. (Although I would prefer to agree on an abstract notion of the resurrection term.) If Jython does things differently, then certainly its behaviour is incompatible

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Antoine Pitrou
On Mon, 27 Oct 2014 18:40:24 +0100 Stefan Richthofer stefan.richtho...@gmx.de wrote: If Jython does things differently, then certainly its behaviour is incompatible with the common expectations of Python developers. Guido recently pointed out that it is allowed for different Python

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Terry Reedy
On 10/27/2014 12:23 PM, Stefan Richthofer wrote: You mean Jython deletes instance attributes before calling __del__ ? No. I think the term of object resurrection usually does not mean bringing back a deleted object in the sense that memory was already freed. I think it rather means that

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-27 Thread Stefan Richthofer
I think 'resuscitation' might be a better metaphor. The term 'resurrection' is not my invention, but well established: http://en.wikipedia.org/wiki/Object_resurrection I well understand why Antoine objects to calling it resurrection in CPython due to implementation specific reasons. But in the

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-26 Thread Stefan Richthofer
You shouldnt have to emulate that. The exact behavior of GC is allowed to vary between systems. Yes, of course. I am looking into this for JyNI, which in contrast should emulate CPython behavior as good as possible. And for such details, -one by one- I am currently weighting up whether its

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-26 Thread Armin Rigo
Hi Stefan, On 26 October 2014 02:50, Stefan Richthofer stefan.richtho...@gmx.de wrote: It appears weakrefs are only cleared if this is done by gc (where no resurrection can happen anyway). If a resurrection-performing-__del__ is just called by ref-count-drop-to-0, weakrefs persist - How do

[Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-25 Thread Stefan Richthofer
Hello developers, I observed strange behaviour in CPython (tested in 2.7.5 and 3.3.3) regarding object resurrection. Yes, resurrection is evil, but it is a valid scenario. If an object is resurrected via its finalizer __del__, sometimes its unique id value as returned from id() changes.

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-25 Thread Antoine Pitrou
Hello Stefan, On Sun, 26 Oct 2014 00:20:47 +0200 Stefan Richthofer stefan.richtho...@gmx.de wrote: Hello developers, I observed strange behaviour in CPython (tested in 2.7.5 and 3.3.3) regarding object resurrection. Your runGC() function is buggy, it does not run the GC under CPython. Fix

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-25 Thread Stefan Richthofer
Okay, sorry, I was thinking too Jython-like. I fixed runGC() just to see now that it does not even trigger resurrection, since under CPython there are no finalizers executed in ref cycles (i.e. I find my objects in gc.garbage). So I realize, my xy_cyclic tests are pointless anyway since in cyclic

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-25 Thread Antoine Pitrou
On Sun, 26 Oct 2014 02:50:39 +0200 Stefan Richthofer stefan.richtho...@gmx.de wrote: Okay, sorry, I was thinking too Jython-like. I fixed runGC() just to see now that it does not even trigger resurrection, since under CPython there are no finalizers executed in ref cycles (i.e. I find my

Re: [Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

2014-10-25 Thread Guido van Rossum
On Saturday, October 25, 2014, Stefan Richthofer stefan.richtho...@gmx.de wrote: Okay, sorry, I was thinking too Jython-like. I fixed runGC() just to see now that it does not even trigger resurrection, since under CPython there are no finalizers executed in ref cycles (i.e. I find my objects