Jeff Schwab <[EMAIL PROTECTED]> writes: > >> In CS, a tuple is a kind of data structure that is specifically not > >> identical with any of its elements. That's the sort of tuple used in > >> Python.
The usual CS meaning of "tuple" is more like the physics meaning than like the Python meaning, I think. > >>>> (a,) is (a,) > > False > > The tuple on the left is not identical with the tuple on the right, > even though they are equivalent. Implementation artifact. It could be constant folded. x = (a,) y = x x is y should print True. > An interesting thing about Python is that numbers of built-in types > are flyweights. Unlike literals of non-flyweight types, distinct > instances of a given numeric literal actually refer to the same object: > > >>> 5 is 5 > True > >>> 999999999999999999999999999999 is 999999999999999999999999999999 > True > >>> 3.5 is 3.5 > True Again an implementation artifact, not guaranteed by the language. Try: (5+1) is (5+1) then try (999999999999999999999999999999+1) is (999999999999999999999999999999+1) -- http://mail.python.org/mailman/listinfo/python-list