[Python-Dev] Changing select.select to accept iterables

Tim Peters tim.one at comcast.net
Sat Sep 6 22:54:34 EDT 2003

[Brett, about <http://www.python.org/sf/798046>]

> I seem to recall that that code has a long history of being hairy
> and full of platform-specific issues, and I'd rather not see it
> disturbed by an unspecific desire for more generalization.  Why can't
> the OP produce the input in the form of lists?

They could, but they specifically already have Sets of socket objects.
That's what C would have used too for select(), if it had sets, so it's a
natural desire.  The SF report notes that when read and write lists change
frequently, it's a lot more efficient to add/remove sockets via O(1) Set
operations.  Under the covers, select() setup takes O(N) time even if the
inputs are native list.

Functions that expect input lists of reasonably small size (thousands, sure;
millions, probably not) can usually be generalized to iterables easily, with
little chance of disruption, by replacing initial "is it a list?" check with
a call to PySequence_Fast(), then

More information about the Python-Dev mailing list