Legitimate use of the "is" comparison operator?
Mike.S.Duffy at gmail.com
Sat Jun 17 10:42:13 CEST 2006
Gary Herron wrote:
> >>> 100 is (99+1)
> >>> 2 is (1+1)
> >>> 100 is 100
> This is highly implementation dependent. The current (C) implementation
> of Python has a cache for small integers, so the attempt to compare
> values with "is" works for some small integers, and fails for some large
> integers, but curiously, not all instances of comparing large integers.
Ahh, thank you. That explains why Fredrick's and Jean-Paul's example
did not work, but mine did (I was using *small* integers). Ok, well I
definitely get the picture. Use the "is" operator for what it was
intended for, or deal with broken code ;-) Thanks a lot guys.
More information about the Python-list