[Python-Dev] I think my set module is ready for prime time; comments?

Eric S. Raymond esr@thyrsus.com
Mon, 22 Jan 2001 15:13:09 -0500


Guido van Rossum <guido@digicool.com>:
> There's already a PEP on a set object type, and everybody and their
> aunt has already implemented a set datatype.

I've just read the PEP.  Greg's proposal has a couple of problems.
The biggest one is that the interface design isn't very Pythonic --
it's formally adequate, but doesn't exploit the extent to which sets
naturally have common semantics with existing Python sequence types.
This is bad; it means that a lot of code that could otherwise ignore
the difference between lists and sets would have to be specialized 
one way or the other for no good reason.

The only other set module I can find in the Vaults or anywhere else is
kjBuckets (which I knew about before).  Looks like a good design, but
complicated -- and requires installation of an extension.

> If *your* set module is ready for prime time, why not publish it in
> the Vaults of Parnassus?

I suppose that's what I'll do if you don't bless it for the standard
library.  But here are the reasons I suggest you should do so:

1. It supports a set of operations that are both often useful and
fiddly to get right, thus enhancing the "batteries are included"
effect.  (I used its ancestor for representing seen-message numbers in
a specialized mailreader, for example.)

2. It's simple for application programmers to use.  No extension module
to integrate.

3. It's unsurprising.  My set objects behave almost exactly like other
mutable sequences, with all the same built-in methods working, except for 
the fact that you can't introduce duplicates with the mutators.

4. It's already completely documented in a form suitable for the library.

5. It's simple enough not to cause you maintainance hassles down the
road, and even if it did the maintainer is unlikely to disappear :-).
-- 
		<a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a>

The United States is in no way founded upon the Christian religion
	-- George Washington & John Adams, in a diplomatic message to Malta.