Unexpected behaviour of getattr(obj, __dict__)
Christos Georgiou
tzot at sil-tec.gr
Thu Feb 16 04:31:30 EST 2006
On Tue, 14 Feb 2006 22:24:12 -0500, rumours say that "Terry Reedy"
<tjreedy at udel.edu> might have written:
>>>>> id(Parrot.f) == id(Parrot.f)
>> True
>>>>> id(Parrot.__dict__) == id(Parrot.__dict__)
>> True
>
>A wrapper is created and passed to id() which returns an int object while
>releasing the wrapper back to the free list. Then another wrapper is
>created in the same chunk of memory and passed to id, which returns an int
>of the same value for comparison. The language ref only guarantees
>uniqueness of ids at any particular instant and allows reuse of ids of
>deallocated objects.
>
>I half seriously think the lib ref entry for id() should have a warning
>that naive use can mislead.
Actually, you more-or-less just wrote what could (I also think should) be
included in the docs.
--
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
More information about the Python-list
mailing list