Message318058
ID numbers in Python are only guaranteed to be unique for the lifespan of the object. In CPython they can be re-used. (In other implementations, like Jython and IronPython, IDs are allocated as sequential numbers and won't be reused.)
The other fact you may be missing is that method objects are generated on the fly each time you look them up. So:
py> class X:
... def method(self): pass
...
py> x = X()
py> a = x.method
py> b = x.method
py> a is b
False
So your example is now understandable: you generate a method object, get its ID, and then the method object is garbage collected, allowing the ID to be reused. Which *in this case* it is. Whether it is or isn't re-used is an accident of implementation.
In other words: nothing to see here. Its not a bug, just the normal behaviour of IDs and garbage collection. |
|
Date |
User |
Action |
Args |
2018-05-29 16:46:29 | steven.daprano | set | recipients:
+ steven.daprano, celicoo |
2018-05-29 16:46:29 | steven.daprano | set | messageid: <1527612389.73.0.682650639539.issue33685@psf.upfronthosting.co.za> |
2018-05-29 16:46:29 | steven.daprano | link | issue33685 messages |
2018-05-29 16:46:29 | steven.daprano | create | |
|