operation complexities of lists and dictionaries

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Mar 29 18:01:10 EST 2006


"xarnaudx at gmail.com" <xarnaudx at gmail.com> writes:

> what are the time complexities of inserting / removing / checking if an
> element is present in 1) a list and 2) a dictionary?

Partly dependent on the implementation, of which there are several for
Python (CPython, Jython, PyPy, and others). Which one are you most
interested in?

> does anybody know?

The 'timeit' module can help you discover the answers for yourself, on
your current implementation.

-- 
 \       "You could augment an earwig to the point where it understood |
  `\     nuclear physics, but it would still be a very stupid thing to |
_o__)                           do!"  -- The Doctor, _The Two Doctors_ |
Ben Finney




More information about the Python-list mailing list