[Python-ideas] set.add() return value

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Thu Feb 12 23:59:08 CET 2009

> * insertion and lookup times are O(1), not O(n log n).

Sorry, I was thinking the .add() is happening inside a loop with N iterations,
with N also being the eventual size of the set. Is O(N log N) correct then?

http://en.wikipedia.org/wiki/Big_O_notation says:

  O(log N) example: finding an item in a sorted array with a binary search.

Isn't that what set is doing?

More information about the Python-ideas mailing list