Thought on PEP 204 and 276

Stephen Horne steve at lurking.demon.co.uk
Tue Jun 4 21:53:12 CEST 2002


On Tue, 4 Jun 2002 10:49:19 -0400, "Steve Holden"
<sholden at holdenweb.com> wrote:

>"phil hunt" <philh at comuno.freeserve.co.uk> wrote in message
>news:slrnaf7mo4.dfe.philh at comuno.freeserve.co.uk...

>> I think they are essentially the same. A sequence tpye is just a
>> mapping type where the keys are restricted to the integers from
>> 0 to however many elements there are minus 1.
>>
>No matter what you think, they are essentially different. Insertion into a
>mapping doesn't alter the key to which other elements are mapped, but
>insertion into a sequence (potentially) does that.

What is normally referred to as insertion in dictionaries is actually
more like overwriting a list element. This is why handling both with
the 'container [key] = value' syntax is natural.

Insertion with modification of existing keys to make room (ie list
insertion) simply does not exist in lists. The usefulness of list
insertion derives from the fact that a list is a very specialised type
of key-to-value mapping - in this respect, the type 'list' should
clearly inheret from and extend the more general key-to-value type
called a dictionary.

In essence, you are confusing the operations on the underlying data
structures with the operations on the conceptual types. These are two
separate concepts. The implementation is distinct from the
user-visible abstraction.




More information about the Python-list mailing list