[Python-Dev] Currently baking idea for dict.sequpdate(iterable, value=True)

Samuele Pedroni pedronis@bluewin.ch
Tue, 26 Nov 2002 01:11:59 +0100


From: "Just van Rossum" <just@letterror.com>
> Fredrik Lundh wrote:
>
> > if the value has no meaning, why not use a set?  how many ways
> > do we need to do the same thing?
>
> True, very true. This basically kills the idea for me.
>

If I understood correctly the not-so-veiled consideration is that sets are
slower and always will be.

"The Sets module met several needs centering around set mathematics;
however, for membership testing, it is so slow that it is almost
always preferable to use dictionaries instead (even without this
proposed method).  The slowness is intrinsic because of the time
to search for the __contains__ method in the class and the time
to setup a try/except to handle mutable elements.  Another reason
to prefer dictionaries is that there is one less thing to import
and expect readers to understand.  My experiences applying the
Sets module indicates that it will *never* replace dictionaries for
membership testing and will have only infrequent use for uniquification."

So the purist solution would be to work long-term on improving set speed.

regards.