[Python-Dev] Tuples vs. lists
Aahz Maruch
aahz@rahul.net
Thu, 24 Jan 2002 10:03:35 -0800 (PST)
Guido van Rossum wrote:
> Aahz:
>>
>> Hrm. Even when it's something that's supposed to be immutable? I'm
>> asking because I'm currently using a tuple for the digit list in my BCD
>> module, and I'd like a clearer explanation of why you think that it
>> should be a list (assuming you do).
>>
>> From my viewpoint, the BCD digit string should be handled like a string;
>> I'm only using a tuple for efficiency of storing numbers instead of
>> characters.
>
> Can't you trust your users not to change it?
Sure, but then I can't just copy references to the tuple when creating a
copy of an instance, I'd have to copy the entire list. That's what I
meant by efficiency. There are important semantic differences coming
from the fact that tuples are immutable and lists are mutable, and I
think that a strict heterogeneous/homogenous distinction loses that.
--
--- Aahz (@pobox.com)
Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
We must not let the evil of a few trample the freedoms of the many.