Created
November 5, 2016 14:04
-
-
Save chendi0x7C00/b45bbc366d9526f5ecd6d441eb7d318f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # coding=UTF-8 | |
| a = "s" | |
| b = "s" | |
| print(id(a)) # python use string interning for short strings | |
| print(id(b)) | |
| assert a is b | |
| assert a == b | |
| c = "x" * 100 | |
| d = "x" * 100 | |
| print(id(c)) | |
| print(id(d)) | |
| assert c is d | |
| assert c == d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment