list index()

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Sep 1 21:53:47 CEST 2007


On Sat, 01 Sep 2007 13:44:28 -0600, Michael L Torrie wrote:

> Alex Martelli wrote:
> 
>> is the "one obvious way to do it" (the set(...) is just a simple and
>> powerful optimization -- checking membership in a set is roughly O(1),
>> while checking membership in a list of N items is O(N)...).
> 
> Depending on a how a set is stored, I'd estimate any membership check in
> a set to be O(log N).

Sets are stored as hash tables so membership check is O(1) just like Alex
said.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list