[Python-Dev] epoll implementation

Ross Cohen rcohen at snurgle.org
Sat May 27 09:00:14 CEST 2006


On Sat, May 27, 2006 at 08:36:12AM +0200, "Martin v. Löwis" wrote:
> Ross Cohen wrote:
> > epoll also allows 64 bits of data to be tucked away and returned when events
> > happen. Could be useful for saving a dict lookup for every event. However,
> > there are some refcounting issues. Dict lookup per event could be traded
> > for one on deregistration. All it needs is a small forward-compatible
> > extension to the current select.poll API.
> 
> I don't understand. You only need the dictionary on registration, to
> find out whether this is a new registration or a modification of an
> existing one. How could you save the dict lookup at registration time?
> And what would you store in the additional data?

The first thing any user of the poll interface does with the file descriptor
is map it to some state object. That's where the lookup can be saved, the
object can just be handed back directly. Problem being that when the fd is
unregistered, we won't get back the PyObject pointer so can't decrement
the refcount, has to be stored and looked up manually.

Ross


More information about the Python-Dev mailing list