[Python-Dev] Adding poll() system call

Andrew Kuchling akuchlin@mems-exchange.org
Tue, 11 Jul 2000 11:28:47 -0400


On Tue, Jul 11, 2000 at 11:09:16AM -0500, Guido van Rossum wrote:
>Somehow I don't understand why we need poll() when we have select(),
>however.  Select() is portable, poll() is Unix specific, but it seems
>to provide the same functionality.  What am I missing?

In addition to /F's quote, poll() also scales better since it only
lists the file descriptors of interest, while select() builds a
bitmap, turns on bits for the fds of interest, and then afterward you
have to scan the whole bitmap again.  It's O(maximum fd), while poll
is O(# of fds), making it more useful for writing more scalable
network servers that service thousands of clients at the same time.

(At the very highest end, even poll() begins to scale badly since you
list "all the open fds", not "all the open fds which have activity".
At that point you're supposed to switch to async I/O, but probably
you'd have switched from Python to C long before that point.)

>This is a nice refactoring opportunity.  The code probably exists in
>many places, e.g. selectmodule.c.  It should be a function in
>fileobject.c, I suppose.

OK; I'll write up a separate patch to do this and submit it first.
(Looks like only select, _tkinter, and poll need this functionality.)

--amk