Behavior of += (was Re: [Python-Dev] Customization docs)

Terry Reedy tjreedy at udel.edu
Wed Jun 5 04:23:40 CEST 2002


"Huaiyu Zhu" <huaiyu at gauss.almadan.ibm.com> wrote in message
news:slrnafqppg.4ea.huaiyu at gauss.almadan.ibm.com...
> Objects are referenced by their ids (or equivalent).  Their memory
location
> may or may not change when it is modified, but if it is the same
object,
> every name that was refering to it will remain referencing to it
after the
> modification, regardless of its memory location.

Conceptually, PyObjects do not even *have* a memory location.  In the
current CPython implementation for computers, they have a *fixed*
location, which happens to be used for the unique integer id.  A
(fixed-location) list object contains a pointer to an auxiliary array
which may be moved when resized.  Same for dicts.

Terry J. Reedy






More information about the Python-list mailing list