It is wrong. There are optimizations for smallish integers to point to the same ram, but generally speaking objects are not aggressively checked for equality, and then aliased. See below code for a small example to illustrate this. Also, doing so would need pretty nifty compile and runtime optimizations proving the properties of the elements of two tuples are in fact immutable and the same. This is not even done on "big" Python, let alone it's smaller cousin.
Code: Select all
>>> a = (255, 0, 0) >>> b = (255, 0, 0) >>> id(a) 1073674352 >>> id(b) 1073674464 >>> c = 255 >>> d = 255 >>> id(c) 511 >>> id(d) 511