[Python-3000] Python-3000 Digest, Vol 2, Issue 151
Antoine Pitrou
solipsis at pitrou.net
Wed Apr 26 17:54:29 CEST 2006
Le mercredi 26 avril 2006 à 11:38 -0400, Jim Jewett a écrit :
> (2) How to make set usage at least as efficient.
> (3) Whether the tradeoffs are worth it.
Well, testing for inclusion in a container of 3 ints may not be
significant vs. all the overhead of the interpreter and vs. what you are
actually doing inbetween the inclusion tests.
That's why I said "*significantly* more efficient" : I think both 3-int
lists and 3-int sets are fast enough, aren't they ?
> Making it as efficient would require changes under the cover. For
> example, sets small enough to fit in smalltable might use a linear
> scan and not bother with hashing.
This optimization is sane with set literals built out of constants for
which you know the comparison is fast.
But searching for an element without hashing may also involve costly
__eq__ calls. Or am I mistaken ?
More information about the Python-3000
mailing list