[Pywikipedia-l] SVN: [6608] trunk/pywikipedia/pagegenerators.py

Russell Blau russblau at imapmail.org
Wed Apr 15 19:41:42 UTC 2009


"Nicolas Dumazet" <nicdumz at gmail.com> said:
> Good, very nice catch =)
>
> A small note here: set is not really meant to be used on incremental
> .add(), because sets are frozen (not mutable), and add() instantiates
> a new set on each .add() action. Sets are useful for set operations
> (union, intersection), but are not really helpful when it comes to
> incrementally construct them. When I need performance for such kind of
> lookups, a simple dictionary is usually way faster than sets :) I
> would suggest using a dictionary here :)

A dict works fine, but to be pedantic about it, sets *are* mutable.  If you 
want a non-mutable set, use the frozenset() type. 
http://docs.python.org/library/stdtypes.html#set-types-set-frozenset

Russ




More information about the Pywikipedia-l mailing list