[Python-Dev] Tuples vs. lists
Aahz Maruch
aahz@rahul.net
Mon, 28 Jan 2002 13:21:58 -0800 (PST)
Guido van Rossum wrote:
> Aahz:
>>
>> 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.
>
> Well, as long as you promise not to change it, you *can* copy a
> reference, right? I guess I don't understand your application
> enough -- do you intend this to be a starting point that is modified
> during the program's execution, or is this a constant array?
It's a constant. The BCD module is Binary Coded Decimal; instances are
intended to be as immutable as strings and numbers (well, it *is* a
number type). Modifying an instance is guaranteed to produce a new
instance. To a large extent, I guess I feel that if a class is intended
to be immutable, each of its underlying data attributes should also be
immutable.
--
--- 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.