[IPython-dev] IPython inputhook, higher rate?

Erik Bray erik.m.bray at gmail.com
Tue Sep 9 13:03:11 EDT 2014


On Tue, Sep 9, 2014 at 12:49 PM, Erik Bray <erik.m.bray at gmail.com> wrote:
> On Thu, Sep 4, 2014 at 12:34 PM, Gustavo Goretkin
> <gustavo.goretkin at gmail.com> wrote:
>>
>> ---------- Forwarded message ----------
>> From: Gustavo Goretkin <gustavo.goretkin at gmail.com>
>> Date: Thu, Aug 28, 2014 at 1:25 PM
>> Subject: IPython inputhook, higher rate?
>> To: ipython-user at scipy.org
>>
>>
>> I'm using IPython.lib.inputhook to run steps in a simulation (Box2D and
>> pygame, which uses sdl). When I run this step in my own loop, I can get many
>> hundred of Hertz. When I use set_inputhook, I can only get 8 Hz. When
>> IPython is integrated with GUI backends (like any of the matplotlib
>> interactive backends), it's very responsive. Is there a setting I'm missing?
>>
>> Thank you!
>> Gustavo
>>
>>
>>
>>>     def run_from_ipython():
>>>         try:
>>>             __IPYTHON__
>>>             return True
>>>         except NameError:
>>>             return False
>>>
>>>     if not run_from_ipython():
>>>         while domain.running:
>>>             domain.run_step()
>>>     else:
>>>         from IPython.lib import inputhook
>>>
>>>         def step():
>>>             domain.run_step()
>>>             return domain.running
>>>
>>>         inputhook.set_inputhook(step)
>
> Hi Gustavo,
>
> I was interested by your email, so I tried reproducing the problem
> with a simple pygame game and encountered the same issue.  Not sure
> what's going on yet though.  The only reference to this I found was
> this message from Fernando some 7 years ago :(
>
> http://mail.scipy.org/pipermail/ipython-dev/2007-November/003333.html
>
> Sounds like there were problems though. I don't know if anyone else
> has resolved them.

My guess is that an inputhook handler for SDL similar to the pyglet
inputhook might be necessary:

https://github.com/ipython/ipython/blob/825f3e480e9d9e4032abab7bc72e5cd086cc3e89/IPython/lib/inputhookpyglet.py

I don't have any more time too look into it right now though.

Erik



More information about the IPython-dev mailing list