ob_refcnt INCREF and so on...
effbot at telia.com
Sun May 28 09:50:56 EDT 2000
jkraska1 at san.rr.com wrote:
> In my efforts to grok references, I wrote a function to print the
> ob_refcnt of python objects so I could test my understanding of
> the reference system.
in other words, you've reimplemented sys.getrefcount:
> In the above code fragment, checkref(o) prints "2". The object "o"
> has two references to it, and I'm not sure why. The closest thing
> I have to a theory is that at the point of creating the argument,
> "o" is assigned to a temporary tuple which grabs a reference count
> to "o" (I based this theory on the knowledge that I have to parse
> a tuple in the C extension code).
that's correct (also see the getrefcount docs).
More information about the Python-list