With Python 2.5, there is a change on the reference count of objects
compared with previous versions (as reported by sys.getrefcount).
All Python versions from 2.1 thru 2.4 gave these same results:
Python 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
2>>import sys
sys.getrefcount(11111111)
1>>sys.getrefcount(11111111+1)
2>>x=22222222
sys.getrefcount(x)
1>>sys.getrefcount(x+1)
2>>sys.getrefcount("A unique *str-ing*")
1>>sys.getrefcount("A unique *str-ing*".upper())
1>>sys.getrefcount(3+2j)
....>>class W: pass
2>>x=W()
sys.getrefcount(x)
1>>sys.getrefcount(W())
But Python 2.5 (2.5.1 not tested yet) gives different results:>>>
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]
on win
32
3>>import sys
sys.getrefcount(11111111)
2>>sys.getrefcount(11111111+1)
2>>x=22222222
sys.getrefcount(x)
1>>sys.getrefcount(x+1)
3>>sys.getrefcount("A unique *str-ing*")
1>>sys.getrefcount("A unique *str-ing*".upper())
2>>sys.getrefcount(3+2j)
....>>class W: pass
2>>x=W()
sys.getrefcount(x)
1>>sys.getrefcount(W())
In particular, I wonder why getrefcount(12341234) returns 3 instead of 2->>>
who is holding the extra reference?
My main two concerns are:
- is there a reference leak somewhere?
- it's a bit harder to debug my own references since I don't know
beforehand the value I should expect from sys.getrefcount()
--
Gabriel Genellina