
Jan Kaliszewski wrote:
Mike Meyer <mwm-keyword-python.b4bdba@mired.org>:
On the other hand, adding negative sets to the language provides an easy way to express that constant, and certainly have more uses in general. If we had to add one of the two, it'd be these. But I'm not convinced that these have enough uses to justify adding them, either.
Yeah, I feel, that if a group of people need them, they should have a separate type ("negative" or "infitity-minus..." or "universe without..."-) sets, in a separate module (not necessarily in std library).
It should definitely start on PyPI. Since most of the work of methods would be done by the underlying system set (or frozenset) type, a Python implementation should be fast enough.
It would be a type which can interact in some ways with sets (like e.g. dict views do...).
As it was noted -- some sets' features don't make sense here... (len, iter).
But many do:
a in universe_minus() -> True
a in universe_minus([a, b, c]) -> False
set([a, b]) < universe_minus() -> True
set([a, b]) < universe_minus([b, c]) -> False
universe_minus().remove(a) -> universe_minus([a])
universe_minus([a, b, c]).remove(a) -> KeyError
universe_minus([a]).add(a) -> universe_minus([])
universe_minus().add(a) -> universe_minus([])
universe_minus() - set([a, b, c]) -> universe_minus([a, b, c])
universe_minus() & set([a, b, c]) -> set([a, b, c])
universe_minus() | set([a, b, c]) -> universe_minus()
universe_minus() - universe_minus([a, b]) -> set([a, b])
universe_minus() & universe_minus([a, b]) -> universe_minus([a, b])
universe_minus() | universe_minus([a, b]) -> universe_minus()
universe_minus([a, b, c]) - set([a, b]) -> universe_minus([a, b, c])
universe_minus([a, b, c]) | set([a, b]) -> universe_minus([c])
universe_minus([a, b]) ^ set([a, b, c]) -> universe_minus([c])
etc.