list storing variables

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Feb 23 21:24:07 EST 2015


Ben Finney wrote:

>> In C language, there is &A for address of A
> 
> There is no “address of a value” concept in Python. You access a value
> by some reference, either a name or an item in a collection. When a
> reference changes to reference some different value, other references
> are not affected.

Furthermore, in Python, values can *change their address*.

Jython and IronPython both are built on top of a garbage collector which can 
move memory around, meaning that objects can end up in a completely 
different location. This makes no difference to Python code, and there is no 
supported way of getting to the address of an object. (In fact, objects may 
be split over multiple locations, even in CPython, e.g. the new optimized 
implementation for dicts has shared storage for keys.)


-- 
Steve




More information about the Python-list mailing list