storing large amounts of data in a list/dictionary

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Fri Mar 11 22:12:00 CET 2005


flamesrock a écrit :
> Hi,
> 
> Basically, what I'm trying to do is store large amounts of data in a
> list or dictionary and then convert that to a custom formatted xml
> file.
> 
> My list looks roughly like this:
> (d[],r[c[d[p[],p[R,C,I]]]])
> 
> My question is, would it be faster to use a dictionary if the elements
> of the lists have to be put in alphebetical order,

 >>> d = {"e" : 32, "f": 44, "a" : 1, "z" : 99}
 >>> for k in d: print k
...
a
z
e
f

Well... Just *don't* rely on *any* order with dicts.

If you need fast keyed access to a very large dataset, you may want to 
have a look at btrees (one possible implementation here : 
http://zopewiki.org/BTree).

Now since it's XML related, this may also (or not) be useful:
http://effbot.org/zone/celementtree.htm
http://effbot.org/zone/element-index.htm

HTH
Bruno





More information about the Python-list mailing list