[Python-Dev] Re: Inline and SWIG

eric jones eric@scipy.org
Thu, 23 Aug 2001 23:05:57 -0400


The scipy.compiler modules (www.scipy.org) is aimed at Numeric
arrays and is slightly different than inlining C code in that it translates
a Python Numeric expression to C++(blitz++ arrays), compiles the
result to a function, and calls it automatically.  It figures out the array
types  the local name space, and keeps up with the compiled module
after the first compile so that they don't have to be compiled again.  The
entire process was greatly eased by Jeremy AST stuff, distutils, and
blitz++.  The most up-to-date description of it is here:

http://www.scipy.org/site_content/tutorials/compiler_notes

Much of this machinery is identical to what is needed for inline C,
and I've tinkered with it a little.  It looks like it won't be extremely
hard (famous last words...) to handle inlining of numeric looping code. The
limited focus on numerical stuff gets around many of the hairy issues
involved
with handling lists of arbitrary types, and got a usable tool out the door
quickly.
Luckily it also attacks the most expensive part of scientific codes and
provides
2-10 speed-up over Numeric array expressions.  I'd like to circle out
from the numeric-only approach and tackle some of the more difficult typing
issues after the numeric stuff all works.  Any input on this thing is
welcome.

Patrick Miller's PyCOD is another compiler that takes a different approach
to compiling (processing bytecodes).  It's a little more ambitious than
scipy.compiler because it handles more than just numeric expressions.  I
don't
know what its release status is either.

The other compiler project I know about is Psyco discussed here:

    http://aspn.activestate.com/ASPN/Mail/Message/609552

It sounds extremely cool and is the most ambitious of the three.  Not sure
how it affects inline C though.  Seems more like this aims to make inline
C obsolete before it even exists.

> I'd recommend that people track down the authors of those modules, as I
> do think there is a great opportunity there.  (I take credit for
> inspiring Eric Jones by mentioning Inline:: to him in Long Beach =).

Heck, if you'll sign up to add support for array broadcasting, I'll name it
scipy.da_compiler...

eric


----- Original Message -----
From: "David Ascher" <DavidA@ActiveState.com>
To: "David Beazley" <beazley@cs.uchicago.edu>
Cc: "Ka-Ping Yee" <ping@lfw.org>; <python-dev@python.org>; <eric@scipy.org>;
<dubois@users.sourceforge.net>; <miller35@llnl.gov>
Sent: Wednesday, August 22, 2001 11:31 PM
Subject: Re: [Python-Dev] Re: Inline and SWIG


> Note that I know of at least two if not three different inline-like
> projects for Python.
>
> One is the compiler module in scipy (Eric Jones & Travis Oliphant):
>
>
http://scipy.net/cgi-bin/viewcvs.cgi/~checkout~/scipy/compiler/doc/readme?re
v=1.2&content-type=text/plain
>
> One is the stuff that Pat Miller from LLNL presented at OSCON in San
> Diego, which sounded similar in spirit (alas, I missed the talk, and
> don't know anything about its availability -- Pat?), and there was a
> third one which I heard mentioned but don't know any details about.
> Eric, do you remember what I'm talking about?
>
> I'd recommend that people track down the authors of those modules, as I
> do think there is a great opportunity there.  (I take credit for
> inspiring Eric Jones by mentioning Inline:: to him in Long Beach =).
>
> --david ascher