-
-
Save sirpengi/1709676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a = lambda x: 1000 | |
>>> a | |
<function <lambda> at 0xb77f88b4> | |
>>> a(1) | |
1000 | |
>>> (id(a(1)), id(a(1))) | |
(143414124, 143414124) | |
>>> (id(a(1)), id(a(2))) | |
(143414124, 143414124) | |
>>> def return_1000(): return 1000 | |
... | |
>>> (id(return_1000()), id(return_1000())) | |
(143414160, 143414160) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> id(1000) | |
143414124 | |
>>> id(9999) | |
143414124 | |
>>> (id(1000), id(9999)) | |
(143414124, 143414208) | |
>>> id(1000); id(9999) | |
143414124 | |
143414208 | |
>>> id(1000); id(1000) | |
143414124 | |
143414124 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[sirpengi@newfie ~]$ cat test.py | |
print id(1000) # 156533708 | |
print id(9999) # 156533684 | |
print id(1000), id(9999) # 156533708 156533684 | |
print id(1000); print id(9999) # 156533708\n 156533684 | |
a = 1000 | |
b = 1000 | |
print id(a) # 156533708 | |
print id(b) # 156533708 | |
print a is b # True | |
c = 999 | |
print id(c) # 156533600 | |
c += 1 | |
print id(c) # 156533540 | |
print c == a # True | |
print c is a # False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment