Suggestion: make sequence and map interfaces more similar
Steven D'Aprano
steve at pearwood.info
Wed Mar 30 12:02:00 EDT 2016
On Wed, 30 Mar 2016 11:50 pm, Random832 wrote:
> Absolutely nothing is stable under a *completely unrestricted* set of
> operations.
Yes, you're absolutely correct. If I create a Python dict, {1: 'a'}, and
then smash the computer to smithereens with a 50lb sledge hammer, neither
the key nor the value will still be accessible. Well done. I never would
have thought of that violation of the dict invariants without you.
>> Specifically, insertions and deletions to the mapping never affect the
>> existing keys.
>
> You can't say that, because there is no insert and delete method in the
> mapping interface.
There are in the dict API though.
# insertions
d[key] = value
# deletions
del d[key]
>> If somebody wants to insist that this is a kind of mapping, I can't
>> disagree, but it isn't useful as a mapping type.
>
> Javascript seems to manage it just fine.
I wouldn't exactly hold Javascript up as the exemplar of intelligent design
decisions.
--
Steven
More information about the Python-list
mailing list