list vs. dict

Jeff Shannon jeff at ccvcorp.com
Thu Feb 28 21:04:24 CET 2002


dsavitsk wrote:

> "Max M" <maxm at mxm.dk> wrote in message news:3C7CFAF8.1080108 at mxm.dk...
>
> > btw: if you really want to store it in a list you can get dict-like
> > behaviour with list speed like this:
>
> is this a python idiom that people often use? cause i've not seen it before,
> but it is really clever.

No, it's not something that people often use.  Generally, if you want dict-like
behavior, you just use a dict.  The times that it's worth the effort to fake the
behavior with something else, are pretty unusual.  The speed difference between
lists and dicts isn't all that significant, anyhow, and which one has the
advantage depends on how you're using it.  Python dicts are pretty amazingly
nifty, really; there's no reason to be shy about using them.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list