pythonrag

Albert Hopkins marduk at letterboxes.org
Mon Apr 5 13:58:08 CEST 2010


On Mon, 2010-04-05 at 11:38 +0000, Jason Friedman wrote:
> I saw this posted in the July issue but did not see any follow-up there:
> 
> $ python
> Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
> [GCC 4.4.1] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> a = 500
> >>> b = 500
> >>> a == b
> True
> >>> a is b
> False
> >>> p = 50
> >>> q = 50
> >>> p == q
> True
> >>> p is q
> True
> >>>

This topic shows here every 3 weeks or so... 

The short of it: CPython optimizes small integers.  It's a feature.
Don't rely on it (Google for the rest).

-a





More information about the Python-list mailing list