[IPython-User] IPython 0.11.x "sluggishness" in pylab mode

Fernando Perez fperez.net@gmail....
Thu Oct 21 19:09:21 CDT 2010

Hey Wes,

On Tue, Oct 19, 2010 at 4:18 PM, Wes McKinney <wesmckinn@gmail.com> wrote:
> start IPython in pylab mode (WXAgg backend default)
> wait 60 seconds
> start typing something, problem present
> %gui (to disable gui backends)
> wait 60 seconds
> start typing something, no lag / hanging
> %gui wx
> wait 60 seconds
> start typing something, problem present

Unfortunately this is a consequence of the new non-threads-based GUI
code, how Wx works, and the desire to be gentle to laptop batteries.

- new gui code doesn't use threads, and instead wires PyOSInputHook
calls into the gui event loop.

- Wx has no notion of a true idle timer that we can hook into, so that
we get called only when idle.

- so we must process all events and then try to sleep.

- sleep too little and we'll use too much cpu even when idle, killing
laptop batteries

- sleep too long and it's sluggish.

So we have a backoff strategy that tries to balance low cpu
consumption with resume times:


Some comments:

- if you use Tk, Qt or GTK, this problem doesn't exist.  It's specific to Wx.

- We're happy to get feedback on improved approaches that make this
better for the user.  We could have the sleep cycle instead be a
user-configurable function so the user decides what sleep strategy he
wants, or hardcode the strategy but leave the *values* of the backoff
tunable by the user, etc...

It's not pretty, any ideas for improvements are welcome.   Or switch
to Qt if you can :) [that's what I'm doing]



More information about the IPython-User mailing list