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

Fernando Perez fperez.net at gmail.com
Tue Sep 8 16:25:09 EDT 2009


On Tue, Sep 8, 2009 at 5:26 AM, Gael Varoquaux
<gael.varoquaux at normalesup.org> wrote:
>
> Take home messages
> -------------------
>
>    - Decorators can be more clever than you think, and my not return
>      objects as simple as you think
>    - Think about pickling, or you'll get bitten at some point
>
>  and most important:
>
>    - Use functools.wraps
>
> Sorry for going off-topic,

Not at all, it's great! Thanks for this nice writeup, it's clear and
informative.

I have to admit that I've never used functools.wraps, because I had
become used to Michele Simonato's excellent decorators module.  In
fact, in ipython we ship internally a copy of it for use in our
testing machinery, as decorators_msim.py.  Perhaps it's time we use it
system-wide and put it in externals, especially since he continues to
improve it so much.  I just had a look and he is still making
releases, it's now on pypi, and has a fantastically well documented
page:

http://pypi.python.org/pypi/decorator

Hell, I just saw that in fact he already has non-"inlined" versions of
@trace, @blocking, @async, etc!

One reason I kept using Michele's code was because functools is
2.5-only, and up until now we were keeping 2.4 compatibility.  But
it's nice to see (I just tested it0 that functools preserves enough of
the decorated function data for ipython foo? introspection to work
nicely (correct name, docstring, signature, etc).

Still, Michele's module is a great little resource in this discussion, I think.

Cheers,

f



More information about the IPython-dev mailing list