Why are there no ordered dictionaries?

Fredrik Lundh fredrik at pythonware.com
Mon Nov 21 02:50:20 EST 2005


bonono at gmail.com wrote:

> Fredrik Lundh wrote:
> > but you can easily generate an index when you need it:
> >
> >     index = dict(d)
> >
> >     name, type = index["pid"]
> >     print name
> >
> > the index should take less than a microsecond to create, and since it
> > points to the members of the original dict, it doesn't use much memory
> > either...
> >
> Using the same logic, we don't need types other than string in a  DBMS
> as we can always convert a string field into some other types when it
> is needed.

No, that's not the same logic.  The dict() in my example doesn't convert be-
tween data types; it provides a new way to view an existing data structure.
There's no parsing involved, nor any type guessing.  And given the use case,
it's more than fast enough, and doesn't copy any data.

If you think that's the same thing as parsing strings, you've completely missed
the point.

</F>






More information about the Python-list mailing list