So are you saying that using a dict means a faster search since you
only need to look up one value? I would think that you would have to look through the keys and stop at the first key that matches since each key has to be uniq, so perhaps if it is nearer the front of the set of keys then perhaps it would be a quicker lookup? On the other hand, if it is nearer the end of the set of keys would it not be slower? Does this make it more dependent on the search order whether a list or a dict is faster? Or am I completely on the wrong track? -h Hari Sekhon Fredrik Lundh wrote: Hari Sekhon wrote:That is surprising since I read on this list recently that lists were faster than dictsdepends on what you're doing with them, of course.It was one reason that was cited as to why local vars are better than> global vars. L[int] is indeed a bit faster than D[string] (but not much), but that doesn't mean that you can loop over *all* items in a list faster than you can look up a single key in a dictionary. </F> |
-- http://mail.python.org/mailman/listinfo/python-list