[IPython-dev] Implementing inline images in a kernel

Doug Blank doug.blank at gmail.com
Wed Jan 29 03:09:08 EST 2014


Here is a nice demo reimagined in Python by colleague Keith O'Hara
demonstrating the physics of plucking a guitar string:

http://nbviewer.ipython.org/urls/bitbucket.org/ipre/calico/raw/master/notebooks/Plucking%20a%20Guitar%20String.ipynb

Change calico.Audio() to the appropriate IPython code, and it should work
there as well.

BTW, how does IPython get the last expression in a set of statements to be
the return value? It can't be an eval(), because it can't handle
statements, and it can't be exec() because it doesn't get the return
value... the only thing it could be would be to parse the statements, and
eval/exec each one?

-Doug


On Wed, Jan 29, 2014 at 2:44 AM, Doug Blank <doug.blank at gmail.com> wrote:

> On Tue, Jan 28, 2014 at 11:41 PM, Fernando Perez <fperez.net at gmail.com>wrote:
>
>>
>> On Tue, Jan 28, 2014 at 6:11 PM, Doug Blank <doug.blank at gmail.com> wrote:
>>
>>> Well, that is probably true in general. But Calico is a very different
>>> kind of beast. It doesn't run the languages independently in their own
>>> space... all of the languages run in the same space. They can share data
>>> and functions and memory, but not by marshaling between systems.
>>
>>
>> Actually, that's sort of how the %julia magics work: we initialize the
>> julia interpreter in-process, by dlopen'ing libjulia and then create a
>> julia interpreter, passing it a pointer to the underlying Python VM.  This
>> allows the two languages to seamlessly share data structures in-memory.
>>
>> I'm not saying that you shouldn't  build your own native kernel, as
>> there's obviously a ton of things that should be done that way (and that's
>> why, in addition to %julia, there's also a real, native julia kernel as
>> Brian mentioned).  I just wanted to point out that language %magics in the
>> IPython kernel aren't limited to working out-of-process.
>>
>>
> That's interesting... IJulia using the Python VM... Then, this is very
> similar to Calico. Because all of the languages share memory, I was able to
> put a global object in there. I have now written display(), HTML(),
> Image(), and Audio(), and all is working very well. HTML, Image, and Audio
> all have a specially named method (similar to Python's __rep__) that when
> called, returns the dictionary of mime-types and strings, and display()
> sends the proper message. Demo to follow...
>
> -Doug
>
>
>> Cheers,
>>
>> f
>>
>>
>> --
>> Fernando Perez (@fperez_org; http://fperez.org)
>> fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
>> fernando.perez-at-berkeley: contact me here for any direct mail
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140129/125b9a7c/attachment.html>


More information about the IPython-dev mailing list