Why are there no ordered dictionaries?
bonono at gmail.com
bonono at gmail.com
Sun Nov 20 19:09:35 EST 2005
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.
Of course there are more than one way to skin a cat(well it may be
against the general idiom of python) but in some situation certain way
is preferred.
More information about the Python-list
mailing list