Skip to content

Instantly share code, notes, and snippets.

@smarnach
Created January 18, 2011 14:10
Show Gist options
  • Save smarnach/784475 to your computer and use it in GitHub Desktop.
Save smarnach/784475 to your computer and use it in GitHub Desktop.
Be careful with object identity of immutable objects in Python (CPython 2.6.6)
In [1]: a = 256
In [2]: b = 256
In [3]: a is b
Out[3]: True
In [4]: a = 257
In [5]: b = 257
In [6]: a is b
Out[6]: False
In [7]: a = 257; b = 257
In [8]: a is b
Out[8]: True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment