list vs. dict
Beda Kosata
kosatab at vscht.cz
Wed Feb 27 09:45:02 EST 2002
Hi,
for a piece of code I need to store relatively large amount of records
(100-1000). Each record will contain few (10-20) pieces of information
(mostly strings or integers).
For convenience it would be better for me to make this records as dicts,
so I don't have to remember what data has what position in the list.
However the most important for me is speed and I suppose that working
with lists is faster than with dicts. So my question is - how much do
lists and dicts differ in speed? The most important is the speed of
comparison ( (dict == dict) vs. (list == list)) and also the speed of
setting and retrieving data (dict[key] = a vs. list[key] = a) and (a =
dict[key] vs. a = list[key]).
Does anyone have some experience? How big the difference between the two
is? I have done some small tests and it seems its not a big difference,
but I don't have any real-world data.
Thanks in advance
BEDA
More information about the Python-list
mailing list