[IPython-dev] wxPython console

Thomas Kluyver takowl at gmail.com
Thu Nov 3 09:25:37 EDT 2011


On 3 November 2011 12:17, Emmanuel Bacry <emmanuel.bacry at polytechnique.fr>wrote:

> 1- I think I understand the solution you suggest. However I don't hink it
> works for me. Let me tell you what ultimately I want to do :
>
> I wrote a pretty big C++ library for displaying and interacting (using
> wxWidget) with scientific plots. It is fast (it is able to manipulate
> really
> long data) and highly interactive.
> My goal is to interface it with python so that I can do computations using
> a
> console and a python interpreter in it. E.g, using numpy to compute some
> stuff that I display and interact with.
> So I want the python interpreter to be ran in the same process as my
> library
> which is using wx so that they share the data.
>
> I am not so sure this is the case in your solution ?
> When you run ipython, there is a python interpreter encapsulated in it
> right
> ?
>
> 2- Now wether the console is running in a different process or not is a
> different problem.
> A priori I don't care if the console runs in a separate process.. though I
> do a little.
> Let me explain why :
> Sometimes, when dealing with scientific data you want to display huge
> quantity of data in the console. You need to have a fast console (look at
> matlab console or R, they display a lot of data very quickly).
> I'm afraid that sending all the stdout through a socket will be kind of
> slow
>
> I don't think the speed of sending output to the console is a big issue.
We use the Qt console for scientific work, and it's normally quite fast
enough, including things like sending base-64 encoded PNGs.

It does make sense, though, that you don't want to keep sending big objects
between two processes. The way we've handled this is to have all the data
and processing in the 'kernel', and use the frontend simply for input and
display. Some version of this approach might work for you, but I don't know
exactly what you're trying to do.

I think it should be possible to create an InteractiveShell object (from
IPython.core.interactiveshell) and use it directly. Some key points:

Instantiation parameters:
config: pass an IPython.config.loader.Config instance to set config values
user_ns: pass a dictionary containing variables which will appear in the
user namespace.
(these, and all the other parameters are optional - omit them for a default
IPython with an empty namespace)

Methods:
run_cell: Run some code as if it had been typed in at the shell.
push: Pass a dictionary of variables to be added to the IPython namespace.
complete: Complete some expression at a prompt (tab completion). See the
docstring for details.
magic: Run a magic command (see %lsmagic)

Also, the InteractiveShell object has a history_manager attribute which
handles input & output history.

At some point, we should probably make an InteractiveShellProxy class
wrapping a kernelmanager so it's easy to switch between in-process and
out-of-process IPython.

Hope that helps,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20111103/b596248e/attachment.html>


More information about the IPython-dev mailing list