[Python-3000] Python-3000 Digest, Vol 2, Issue 151

Jim Jewett jimjjewett at gmail.com
Wed Apr 26 17:38:22 CEST 2006


On 4/26/06, Antoine Pitrou <solipsis at pitrou.net> wrote:
> 2) set([1,2,3]) makes little sense anyway, since it
> probably isn't significantly more efficient than [1,2,3]

In the current implementation, is is less efficient.

But a set is what you really intend; using a list simply because it is
currently more efficient is a bad thing to encourage.

The questions are

(1)  How to make set usage at least as easy as list/tuple.
(2)  How to make set usage at least as efficient.
(3)  Whether the tradeoffs are worth it.

{1, 2, 3} as literal notation for a set makes it as easy (though there
will still be habit to break).

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.

Both of these add complication to the langauge.  Is doing the
"correct" thing instead of "close enough" important enough to justify
the changes?

-jJ


More information about the Python-3000 mailing list