[IPython-dev] Musings: syntax for high-level expression of parallel (and other) execution control

Fernando Perez fperez.net@gmail....
Tue Sep 8 12:46:43 CDT 2009

On Sun, Sep 6, 2009 at 12:14 AM, Prabhu Ramachandran
<prabhu@aero.iitb.ac.in> wrote:

> Thanks for the interesting links and thread.  Just FYI, last year I had
> occasion to solve, relatively elegantly, a set of pretty sticky problems for
> mayavi2 using decorators and generators.  See for example:
> https://svn.enthought.com/enthought/browser/Mayavi/trunk/enthought/mayavi/tools/show.py
> https://svn.enthought.com/enthought/browser/Mayavi/trunk/enthought/mayavi/tools/animator.py

Very nice code, thanks for the pointers.  I particularly like how you
handled (at the inevitable cost of some extra code in your decorators)
the slight annoyance that typical decorators whose arguments are
optional need to be called in the no-arg case as

def bar (): ...

so the first call to foo() resolves out.  Your code permits instead
the cleaner-looking (for the user at least):

@foo(x, y)   # with args
def bar(): ...

@foo    # foo without args
def baz(): ...

> They allow us to do relatively simple but neat things very elegantly. Until
> you use decorators you often don't realize how convenient they can be.  In
> particular the pattern used in animator.py shows how convenient the
> combination of a UI dispatch mechanism plus a generator is.  All a
> programmer needs is to inject a yield suitably and the rest is automatic.
> The Kamaelia project (http://www.kamaelia.org) is also very interesting for
> its use of generators, microprocesses, components and very specifically
> concurrency.  They have a very neat model for exactly this and a nice though
> slightly elaborate tutorial showing how you can build their core library
> from these ideas.  If you have the time it is very interesting.

I remember reading about Kamaelia a while ago, and thinking that it
felt like a relly well laid out and intelligently done project.  I
should probably revisit it, thanks for the reminder.

> My humble contribution to spending two more hours of your time. ;-)

Well, I didn't bite this time :)  It really was critical that I push
on reviewing Brian's excellent recent work to avoid bottlenecking him
any further, so my labor day holiday was productively spent on ipython
yesterday (and sphinx exercises, for a paper).  I'm glad I got it
done, because I missed a trip to the Monterrey aquarium with my family
and the pictures they brought back were really nice, so at least I
didn't stay home for nothing :)



More information about the IPython-dev mailing list