John Machin schrieb:
*IF* you need to access the regex associated with a token in O(1) time, a dict is indicated.
O(1) - Does that mean `mydict[mykey]` takes the same amount of time, no matter if mydict has 10 or 1000000000 entries? How does this magic work? O(log n) I would understand, but constant time?
If you have *both* requirements simultaneously, then *both* list and dict are indicated.
So I would have to duplicate my data and store it once in a list, once in a dict? Or should I decide for one way and accept that one type of access will not be optimal?
Greetings, Thomas -- Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison! (Coluche) -- http://mail.python.org/mailman/listinfo/python-list