[Python-ideas] The async API of the future

Sam Rushing sam-pydeas at rushing.nightmare.com
Tue Nov 6 20:43:57 CET 2012


On 11/6/12 7:41 AM, Ben Darnell wrote:
> Yes.  When the server processes a request and switches from listening
> for readability to listening for writability, with epoll it's one call
> directly into the C module to set the event mask for the socket.  With
> kqueue something in the IOLoop must store the previous state and
> generate the two separate actions to remove the read listener and add
> a write listener.

Does that mean you're not using EV_ONESHOT?

>  I misspoke when I mentioned system call; the difference is actually
> the amount of python code that must be run to call the right C
> functions.  This would get a lot better if more of the IOLoop were
> written in C.

That's what we did with shrapnel, though we split the difference and
wrote everything in Pyrex.

> True, although whenever I've tried to be clever and batch up kevent
> calls I haven't gotten the performance I'd hoped for because system
> calls aren't actually that expensive in comparison to python opcodes.
>

And yeah, of course all this is dominated by time in the python VM...
Also, you still have to execute all the read/write system calls, so it
only cuts it in half.

-Sam




More information about the Python-ideas mailing list