Skip to content

Instantly share code, notes, and snippets.

@narfdotpl
Created September 15, 2013 08:09
Show Gist options
  • Save narfdotpl/6568808 to your computer and use it in GitHub Desktop.
Save narfdotpl/6568808 to your computer and use it in GitHub Desktop.
integer allocation in Python
$ python2.7
Python 2.7.2 (default, Oct 17 2011, 00:04:42)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> result = None
>>> for n in range(1000):
... m = int(str(n))
... previous_result = result
... result = n is m
... if result != previous_result:
... print n, result
...
0 True
257 False
>>>
$ python3.3
Python 3.3.1 (default, Sep 15 2013, 10:03:49)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> result = None
>>> for n in range(1000):
... m = int(str(n))
... previous_result = result
... result = n is m
... if result != previous_result:
... print(n, result)
...
0 True
257 False
>>>
@narfdotpl
Copy link
Author

/cc @PawelStiasny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment