[Cython] Wacky idea: proper macros

Dag Sverre Seljebotn d.s.seljebotn at astro.uio.no
Mon Apr 30 23:32:58 CEST 2012

Wes McKinney <wesmckinn at gmail.com> wrote:

>On Mon, Apr 30, 2012 at 4:55 PM, Nathaniel Smith <njs at pobox.com> wrote:
>> On Mon, Apr 30, 2012 at 9:49 PM, Dag Sverre Seljebotn
>> <d.s.seljebotn at astro.uio.no> wrote:
>>> JIT is really the way to go. It is one thing that a JIT could
>optimize the
>>> case where you pass a callback to a function and inline it run-time.
>>> even if it doesn't get that fancy, it'd be great to just be able to
>>> something like "cython.eval(s)" and have that be compiled (I guess
>you could
>>> do that now, but the sheer overhead of the C compiler and all the
>.so files
>>> involved means nobody would sanely use that as the main way of
>>> together something like pandas).
>> The overhead of running a fully optimizing compiler over pandas on
>> every import is pretty high, though. You can come up with various
>> caching mechanisms, but they all mean introducing some kind of
>> time/run time distinction. So I'm skeptical we'll just be able to get
>> rid of that concept, even in a brave new LLVM/PyPy/Julia world.
>> -- Nathaniel
>> _______________________________________________
>> cython-devel mailing list
>> cython-devel at python.org
>> http://mail.python.org/mailman/listinfo/cython-devel
>I'd be perfectly OK with just having to compile pandas's "data engine"
>and generate loads of C/C++ code. JIT-compiling little array
>expressions would be cool too. I've got enough of an itch that I might
>have to start scratching pretty soon.

I think a good start is:

Myself I'd look into just using Jinja2 to generate all the Cython code, rather than those horrible Python interpolated strings...that should give you something that's at least rather pleasant for you to work with once you are used to it (even if it is a bit horrible to newcomers to the code base).

You can even check in the generated sources.

And we've discussed letting cython be smart with templating languages and error report on a line in the original template, such features will certainly accepted once somebody codes it up.

 (I can give you me breakdown of how I eliminate other templating languages than Jinja2 for this purpose tomorrow if you are interested).


>cython-devel mailing list
>cython-devel at python.org

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

More information about the cython-devel mailing list