Tuples and immutability

Mark H. Harris harrismh777 at gmail.com
Sat Mar 1 05:45:56 CET 2014

On Friday, February 28, 2014 7:27:17 PM UTC-6, Eric Jacoboni wrote:

> I agree with that too... My error was to first consider the list, then
> the tuple... I should have considered the tuple first...
> Anyway, the TypeError should rollback, not commit the mistake.

I believe so too,  but I'm not one of the core devs.  And they do not agree. 

Ever since day one with me and python I have questioned whether a tuple even makes sense.  Well, certainly it does, because it has so much less overhead and yet it acts like a list (which for so many situations thats really what we want anyway... a list, that never changes).  Tuples are great, for what they are designed to do.

But now consider,  why would I purposely want to place a mutable object within an immutable list?  A valid question of high importance.  Why indeed?  

I really believe IMHO that the error should have come when you made the list an item of a tuple.  An immutable object should have NO REASON to contain a mutable  object like list... I mean the whole point is to eliminate the overhead of a list ... why would the python interpreter allow you to place a mutable object within an immutable list in the first place.   This is just philosophical, and yes, the core dev's are not going to agree with me on this either.

I think the situation is interesting for sure... and it will surface again, you can count on that.


More information about the Python-list mailing list