Ctypes based prototype of PyOS_InputHook for wx 2.8 and 2.9

Hi,

I am attaching a working ctypes based prototype of a module that allows wx to be used interactively from both python and ipython. It uses PyOS_InputHook and has been tested on wx 2.8 and 2.9 (trunk) on Mac OS X (python 2.5).

It can be used with an existing wx install and all versions of ipython, but don’t use the -pylab or -wthread flag. At this point, I need help testing the heck out of this (window and linux users esp). I have run most matplotlib pylab_examples and they work fine. I also need people to try out things like ETS/Mayavi. The current plan is to replace the existing threaded shells in IPython with this (much simpler) code.

Cheers,

Brian

inputhook.py (1.99 KB)

I won't be able to do that reliably before two weeks, I am travelling and
have deadlines on top of that. Maybe somebody else can try this?

Cheers,

Ga�l

···

On Thu, Jul 16, 2009 at 03:26:23PM -0700, Brian Granger wrote:

   I am attaching a working ctypes based prototype of a module that allows wx
   to be used interactively from *both* python and ipython.� It uses
   PyOS_InputHook and has been tested on wx 2.8 and 2.9 (trunk) on Mac OS X
   (python 2.5).

   It can be used with an existing wx install and all versions of ipython,
   but ***don't use the -pylab or -wthread flag***.� At this point, I need
   help testing the heck out of this (window and linux users esp).� I have
   run most matplotlib pylab_examples and they work fine.� I also need people
   to try out things like ETS/Mayavi.� The current plan is to replace the
   existing threaded shells in IPython with this (much simpler) code.

Works for me with wx 2.8.8.1 on OS X 10.5 and Chaco. Pan and zoom
interactions are substantially chunky, though. I do not see such
chunkiness with -wthread. It would be worth exploring a Cython
alternative to see if it is just ctypes and general Python overhead to
blame.

···

On Thu, Jul 16, 2009 at 17:26, Brian Granger<ellisonbg.net@...149...> wrote:

Hi,

I am attaching a working ctypes based prototype of a module that allows wx
to be used interactively from *both* python and ipython. It uses
PyOS_InputHook and has been tested on wx 2.8 and 2.9 (trunk) on Mac OS X
(python 2.5).

It can be used with an existing wx install and all versions of ipython, but
***don't use the -pylab or -wthread flag***. At this point, I need help
testing the heck out of this (window and linux users esp). I have run most
matplotlib pylab_examples and they work fine. I also need people to try out
things like ETS/Mayavi. The current plan is to replace the existing
threaded shells in IPython with this (much simpler) code.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

Robert,

Thanks for testing this so quickly. Performance is one of the big issues that I am concerned about. I will work on a Cython based version to see if that solves the problem.

Cheers,

Brian

···

Works for me with wx 2.8.8.1 on OS X 10.5 and Chaco. Pan and zoom

interactions are substantially chunky, though. I do not see such

chunkiness with -wthread. It would be worth exploring a Cython

alternative to see if it is just ctypes and general Python overhead to

blame.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless

enigma that is made terrible by our own mad attempt to interpret it as

though it had an underlying truth."

– Umberto Eco


IPython-dev mailing list

IPython-dev@…336…

http://mail.scipy.org/mailman/listinfo/ipython-dev

Works for me on Ubuntu 9.04 with default packages (wx 2.8.9.1), I
tried this example:

In [1]: import inputhook

In [2]: inputhook.set_inputhook_wx()

In [3]: app = wx.App(redirect=False, clearSigInt=False)

···

On Thu, Jul 16, 2009 at 4:42 PM, Robert Kern<rkern@...492...> wrote:

On Thu, Jul 16, 2009 at 17:26, Brian Granger<ellisonbg.net@...149...> wrote:

Hi,

I am attaching a working ctypes based prototype of a module that allows wx
to be used interactively from *both* python and ipython. It uses
PyOS_InputHook and has been tested on wx 2.8 and 2.9 (trunk) on Mac OS X
(python 2.5).

It can be used with an existing wx install and all versions of ipython, but
***don't use the -pylab or -wthread flag***. At this point, I need help
testing the heck out of this (window and linux users esp). I have run most
matplotlib pylab_examples and they work fine. I also need people to try out
things like ETS/Mayavi. The current plan is to replace the existing
threaded shells in IPython with this (much simpler) code.

Works for me with wx 2.8.8.1 on OS X 10.5 and Chaco. Pan and zoom
interactions are substantially chunky, though. I do not see such
chunkiness with -wthread. It would be worth exploring a Cython
alternative to see if it is just ctypes and general Python overhead to
blame.

---------------------------------------------------------------------------
NameError Traceback (most recent call last)

/home/ondrej/Desktop/<ipython console> in <module>()

NameError: name 'wx' is not defined

In [4]: import wx

In [5]: app = wx.App(redirect=False, clearSigInt=False)

In [6]: from matplotlib import pyplot as plt

In [7]: plt.interactive(True)

In [8]: plt.plot(range(10))
Out[8]: [<matplotlib.lines.Line2D object at 0x3917090>]

(maybe you want to add "import wx" into that example docstring)

Pan is perfectly smooth, zoom is a bit chunky, but not much, it's
definitely usable.

Ondrej

I also tested mayavi, this demo:

and I didn't notice any speed difference --- e.g. it's as slow as
regular mayavi with ipython -wthread. :slight_smile:

Ondrej

···

On Thu, Jul 16, 2009 at 11:11 PM, Ondrej Certik<ondrej@...583...> wrote:

On Thu, Jul 16, 2009 at 4:42 PM, Robert Kern<rkern@...492...> wrote:

On Thu, Jul 16, 2009 at 17:26, Brian Granger<ellisonbg.net@...149...> wrote:

Hi,

I am attaching a working ctypes based prototype of a module that allows wx
to be used interactively from *both* python and ipython. It uses
PyOS_InputHook and has been tested on wx 2.8 and 2.9 (trunk) on Mac OS X
(python 2.5).

It can be used with an existing wx install and all versions of ipython, but
***don't use the -pylab or -wthread flag***. At this point, I need help
testing the heck out of this (window and linux users esp). I have run most
matplotlib pylab_examples and they work fine. I also need people to try out
things like ETS/Mayavi. The current plan is to replace the existing
threaded shells in IPython with this (much simpler) code.

Works for me with wx 2.8.8.1 on OS X 10.5 and Chaco. Pan and zoom
interactions are substantially chunky, though. I do not see such
chunkiness with -wthread. It would be worth exploring a Cython
alternative to see if it is just ctypes and general Python overhead to
blame.

Works for me on Ubuntu 9.04 with default packages (wx 2.8.9.1), I
tried this example:

In [1]: import inputhook

In [2]: inputhook.set_inputhook_wx()

In [3]: app = wx.App(redirect=False, clearSigInt=False)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)

/home/ondrej/Desktop/<ipython console> in <module>()

NameError: name 'wx' is not defined

In [4]: import wx

In [5]: app = wx.App(redirect=False, clearSigInt=False)

In [6]: from matplotlib import pyplot as plt

In [7]: plt.interactive(True)

In [8]: plt.plot(range(10))
Out[8]: [<matplotlib.lines.Line2D object at 0x3917090>]

(maybe you want to add "import wx" into that example docstring)

Pan is perfectly smooth, zoom is a bit chunky, but not much, it's
definitely usable.

Nice, nice!

Test the volume_slicer example, with latest release, please. That should
be a good test.

Gaël

···

On Thu, Jul 16, 2009 at 11:27:51PM -0600, Ondrej Certik wrote:

and I didn't notice any speed difference --- e.g. it's as slow as
regular mayavi with ipython -wthread. :slight_smile:

All,

I have an improved prototype of my ctypes based inputhook for wx. In this version I have:

  • Added and tested Ondrej’s patch. It seems to improve both responsiveness and idle GPU load. Thanks Ondrej!
  • Tested on Win32
  • Small changes related to the GIL.

Robert and Gael, can you test this version (with approach 3) to see if it is satisfactory in terms of performance AND idle CPU load. On my system MacBook Pro, the idle load is now below 1%.

Cheers and thanks,

Brian

inputhook.py (6.34 KB)