I read the Python 2 docs and noticed the id()
function:
Return the “identity” of an object. This is an integer (or long integer) which is
That's the identity of the location of the object in memory...
This example might help you understand the concept a little more.
foo = 1
bar = foo
baz = bar
fii = 1
print id(foo)
print id(bar)
print id(baz)
print id(fii)
> 1532352
> 1532352
> 1532352
> 1532352
These all point to the same location in memory, which is why their values are the same. In the example, 1
is only stored once, and anything else pointing to 1
will reference that memory location.