[Python-Dev] Using lists as sets

Ken Manheimer klm@digicool.com
Fri, 17 Mar 2000 19:32:56 -0500 (EST)


On Fri, 17 Mar 2000, Ka-Ping Yee wrote:

> On Fri, 17 Mar 2000, David Ascher wrote:
> > > I think the semantics would be pretty understandable and simple to
> > > explain, which is the main thing.
> > >
> > > Any thoughts?
> > 
> > Would
> > 
> > 	(a,b) in Set
> > 
> > return true of (a,b) was a subset of Set, or if (a,b) was an element of Set?
> 
> This would return true if (a, b) was an element of the set --
> exactly the same semantics as we currently have for lists.

I really like the idea of using dynamically-tuned lists provide set
functionality!  I often wind up needing something like set functionality,
and implementing little convenience routines (unique, difference, etc)
repeatedly.  I don't mind that so much, but the frequency signifies that
i, at least, would benefit from built-in support for sets...

I guess the question is whether it's practical to come up with a
reasonably adequate, reasonably general dynamic optimization strategy.  
Seems like an interesting challenge - is there prior art?

As ping says, maintaining the existing list semantics handily answers
challenges like david's question.  New methods, like [].subset('a', 'b'),
could provide the desired additional functionality - and contribute to
biasing the object towards set optimization, etc.  Neato!

Ken
klm@digicool.com