"Fuzzyman" wrote: > [snip..] > > (as an example, on my machine, using Foord's OrderedDict class > > on Zwerschke's example, creating the dictionary in the first place > > takes 5 times longer than the index approach, and accessing an > > item takes 3 times longer. you can in fact recreate the index 6 > > times before OrderedDict is faster; if you keep the index around, > > the OrderedDict approach never wins...) > > So, so long as you want to use the dictionary less than six times - > it's faster to store/access it as a list of tuples. ;-)
nope. that's not what I said. I said that you can recreate the index six times in the time it takes to create a single OrderedDict instance. if you need to use index more than that, it's not that hard to keep a reference to it. > Everytime you want to access (or assign to) the data structure as a > dictionary, you have to re-create the index. the use case we're talking about here (field descriptors) doesn't involve assigning to the data structure, once it's created. I'll repeat this one last time: for the use cases presented by Zwerschke and "bonono", using a list as the master data structure, and creating the dictionary on demand, is a lot faster than using a ready-made ordered dict implementation. if you will access things via the dictionary a lot, you can cache the dictionary somewhere. if not, you can recreate it several times and still get a net win. for other use cases, things may be different, but nobody has presented such a use case yet. as I said earlier, "let's assume we have another use case" is not a valid use case. </F> -- http://mail.python.org/mailman/listinfo/python-list