[Python-3000] Set literal

Raymond Hettinger python at rcn.com
Fri Jan 25 01:46:37 CET 2008


[John Barham]
> But getting back to the original issue, what does using
> frozensets gain you over using a tuple:
>
> if urlext in ('html', 'xml', 'php'):

With sets, the search is O(1).
With tuples, it is O(n).
Sets win on inputs longer than 1.


Raymond


More information about the Python-3000 mailing list