[IPython-dev] IPython inputhook, higher rate?

Martin Teichmann lkb.teichmann at gmail.com
Tue Sep 30 11:05:57 EDT 2014


Hi,

I just saw this thread about why and how the python
inputhook works, and how to integrate other event loops
with IPython, using said input hooks.

The actual problem is that the python input routine blocks
while it reads from the console. This is completely
unnecessary, as the underlying GNU readline library does
not require a block at all. Down in the python interpreter,
something like the following happens (it's in C in original).

while True:
    PyOS_InputHook()
    select(stdin, timeout=100)
    if something_in_stdin:
        call_GNU_readline_to_read_one_char()

so, python defines its own event loop! As one can see
very clearly, from the IPython standpoint this is completely
stupid: we want our own event loop to run (eg, the Qt
event loop), and once something arrives at stdin, call
GNU readline to process whatever arrived.

I already wrote the necessary changes and already put
up some patch on the python issue tracker:
http://bugs.python.org/issue22412

Greetings

Martin



More information about the IPython-dev mailing list