I'm using Python 2.3.4

After reading this in the docs
getrefcount( object)
Return the reference count of the object. The count returned is generally one higher than you might expect, because it includes the (temporary) reference as an argument to getrefcount().
I decided to try some experiments

 class junk(object):
...     pass
...
>>> sys.getrefcount(junk)
5
>>> j1=junk()
>>> sys.getrefcount(junk)
6

sys.getrefcount(j1)
2

I understand why j1 is 1 higher than I expect, based on the docs, but why does getrefcount(junk) return 5 before any instances of class junk are made?




_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to