Paul Rudin <paul.nos...@rudin.co.uk> writes: > Terry Reedy <tjre...@udel.edu> writes: > >> Suppose I write an nasty C extension that mutates tuples. What then >> would be illegal about... > > Depends on exactly what we mean by legal. If immutability is part of the > language spec (rather than an artifact of a particular implementation) > then a compiler could assume immutability.
And, indeed, it does exactly that. Tuples of constant literals are created at compilation time and reused across function invocations. Mutating a tuple using a C extension is "illegal" in that it breaks the rules of the system, by changing the semantics of valid code in unexpected ways. A more extreme example of this would be mutating the constant 0 or the empty tuple. -- http://mail.python.org/mailman/listinfo/python-list