references and buffer()

Carl Friedrich Bolz cfbolz at gmx.de
Sun Oct 8 15:16:13 EDT 2006


Fredrik Lundh wrote:
[snip]
>> is id similar to the address of a variable or a class ?
>
> in the CPython implementation, it's the address where the object is
> stored.  but that's an implementation detail.

Just as an obscure sidenote, in PyPy it is ~address some of the time.
This is due to the fact that since PyPy can use the Boehm garbage
collector. The Boehm collector is conservative and therefore has to
assume that everything in RAM could be a pointer. Now if somebody stores
the id of an object the GC could not distinguish this from a real pointer
if id returned the address, which would keep the object alive.

</sidenode>

Cheers,

Carl Friedrich Bolz




More information about the Python-list mailing list