ob_refcnt INCREF and so on...
mwh21 at cam.ac.uk
Sun May 28 00:00:49 CEST 2000
Courageous <jkraska1 at san.rr.com> writes:
> Can someone confirm or deny this, and if I'm mistaken, explain why
> the refcnt of the object is 2 at the point where I print it??????
> If correct, is there a predictable time when the temporary will
> lose it's reference hold on the object?
YHBT-M (You Have Been Time-Machined):
>>> print sys.getrefcount.__doc__
getrefcount(object) -> integer
Return the current reference count for the object. This includes the
temporary reference in the argument list, so it is at least 2.
The reference will go away after the function returns. Read the
source for the CALL_FUNCTION opcode(s if you're in 1.6aX) for the gory
(and I do mean gory) details.
The comment isn't strictly true, either:
>>> class C:
3. Syntactic sugar causes cancer of the semicolon.
-- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html
More information about the Python-list