Interesting behaviour of the assignment
Oleg Broytmann
phd at phd.pp.ru
Thu Dec 28 09:15:05 EST 2000
On Thu, 28 Dec 2000, June Kim wrote:
> >>> a=100
> >>> b=100
> >>> a is b
> 0
> >>> a=99
> >>> b=99
> >>> a is b
> 1
>
> Is this an intended/expected result? What is the lying structure beneath
> this?
First 100 integers (0-99) are preallocated by interpreter. So every time
you use it - the same object is used. All other integers are allocated anew
every time.
Oleg.
----
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list