Benjamin  <[EMAIL PROTECTED]> wrote:
>> [ help(sys.getrefcount) says: ]
>> [ ... ]  The count returned is generally
>> one higher than you might expect, because it includes the (temporary)
>> reference as an argument to getrefcount().
>Are there any cases when it wouldn't?

When the temporary reference which is the argument to getrefcount is
the *only* reference, eg:

>>> sys.getrefcount (set())
1

The return value for a weakly referenced object may also be not what
you "expect":

>>> s = set()
>>> sys.getrefcount(s)
2
>>> r = weakref.ref(s)
>>> r() is s
True
>>> sys.getrefcount(r())
2

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
        -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to