Performance: sets vs dicts.

Ben Finney ben+python at
Mon Aug 30 16:02:33 CEST 2010

aahz at (Aahz) writes:

> That reminds me: one co-worker (who really should have known better ;-)
> had the impression that sets were O(N) rather than O(1).

For settling exactly this kind of confusion, Python's standard library
comes with a module, the ‘timeit’ module. Your co-worker should have
known better: don't guess about timing performance, measure it.

Or am I missing something here?

 \       “If you don't know what your program is supposed to do, you'd |
  `\                 better not start writing it.” —Edsger W. Dijkstra |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list