A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-May/064979.html below:

[Python-Dev] Efficient set complement and operation on large/infinite sets.

[Python-Dev] Efficient set complement and operation on large/infinite sets. [Python-Dev] Efficient set complement and operation on large/infinite sets.Terry Jones terry at jon.es
Fri May 12 01:33:10 CEST 2006
A quick followup to my own posting:

I meant to say something about implementing __rand__() and pop(). I'd
either add another optional function argument to the constructor. It would
return a random element from the universe. Then for __rand__() and pop(),
you'd call until it (hopefully!) returned something not excluded. Or, do
something non-random, like return a random (non-excluded) integer. Or, just
raise an exception.

I think I prefer the extra argument approach, where the docs state clearly
that you can expect to wait longer and longer for random elements as you
empty a finite inverted set. I prefer this approach because getting a
random element from a set is something you really should be able to
do. Just raising an exception is the cleanest and clearest choice.

One thing I certainly would not consider is trying to mess around with the
excluded set (which may in any case be empty) to figure out a suitable
return type.

And yes, I agree in advance, adding 5 new optional arguments to the set()
constructor isn't pretty. Is the added functionality is worth it?

Terry
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4