This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: select module doesn't allow any iterable.
Type: enhancement Stage:
Components: None Versions:
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: arigo, brett.cannon, jemfinch
Priority: normal Keywords:

Created on 2003-08-31 07:31 by jemfinch, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Messages (4)
msg53990 - (view) Author: Jeremy Fincher (jemfinch) Date: 2003-08-31 07:31
The select module only allows lists, not any 
iterable.  While this may slightly increase efficiency 
for the function itself, for many 
applications passing a sets.Set would 
probably be much more efficient (i.e., when things 
are being added/removed from the readable or 
writable lists quite often, the O(n) removal of lists 
would certainly be worse than the O(1) removal of 
msg53991 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2003-09-02 18:23
Logged In: YES 

Using select.poll() instead of might be a
good alternative, at least on platforms that support it, if
the sets are getting large enough for you to want to avoid
having to build lists explicitely as in :, list(b), list(c))
msg53992 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-09-06 22:22
Logged In: YES 

There seems to be two things that are preventing the use of an 
object that supports the iterator protocol instead of a list.  One is 
the explicit check that the arguments are lists; PyList_Check is run 
on the passed-in lists for a basic sanity check.  Then there is a call 
to a function called list2set that takes in a Python list and then 
sets the passed-in fd_set properly.  In that function there is 
nothing that screams "we should only use lists" beyond it allows 
assuming a list and thus doesn't have any hoops to jump through.

But the iterator protocol was set up to minimize hoop jumping.  
There seems to be little stopping a move over to using the iterator 
protocol beyond a minimial amount of recoding to rip out the list 
check to replace it with PyIter_Check and instead of using a 'for' 
loop through a list you just use a 'while' calling PyIter_Next .

But since this seems to have gone so long without being changed I 
would feel better about having someone tell me it is okay to 
change.  I will email python-dev and ask.
msg53993 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-09-10 19:39
Logged In: YES 

Rev. 2.74 of Modules/selectmodule.c has accept a 
sequence (as defined by PySequence_Fast()) for its first three 
arguments; this includes sets.

Changed to an RFE since it wasn't really a bug and closed.
Date User Action Args
2022-04-10 16:10:55adminsetgithub: 39154
2003-08-31 07:31:15jemfinchcreate