Ordered dict by default

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Feb 6 18:19:22 EST 2009


Cameron Simpson:

>increases the unrealised assumptions about mappings in general which a newbie may acquire, causing them pain/complaint later with other mappings<

This is wrong in several different ways.


> I would much rather keep dictionaries as performant as possible, as a
> bare mapping, and add an odict for when order matters.

In Python 3 strings are all unicode, integral numbers are all
multiprecision, chars in Python 2.x+ are strings, lists are arrays
that can grow dynamically, and so on because the Purpose of Python
isn't to be as fast as possible, but to be first of all flexible,
safe, easy, not but-prone, even if other solution or older versions
were faster. Ruby shares almost same purposes.

I presume Ruby wants to become a bit higher level than Python, because
it now has a more flexible built-in. But even in a language designed
to run way faster than Python, like D, I think the right thing for
built-ins is to be as flexible&easy as possible, so they are good
enough in as many situations as possible, where performance isn't the
most important thing, and to put the more specialized and faster
versions into external libs. Making the built-ins be as optimized as
possible (but limited too) looks like premature optimization to me,
and in a language like Python premature optimization looks even more
silly than usual.

Bye,
bearophile



More information about the Python-list mailing list