On Tue, Dec 15, 2015 at 01:54:30AM +0000, Alan Gauld wrote:

> This behaviour should never be relied on since the definition
> of a "small int" is potentially implementation dependant and
> could even change with Python version or platform. Always
> use == to test integers.

It isn't just *potentially* implementation dependent, it certainly is 
implementation dependant.

Different versions of Python have used different rules for which small 
ints are cached, and the rules for when they will be re-used or cached. 
For example, this is with Python 2.7:


py> a = 100001
py> b = 100001
py> a is b
False
py> a = 100002; b = 100002
py> a is b
True


You CANNOT rely on this behaviour, it WILL change from version to 
version.



-- 
Steve
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to