Lambda the Ultimate

inactiveTopic Pyrex - A language for writing Python extension modules
started 4/20/2002; 9:13:01 AM - last post 8/10/2002; 5:01:17 PM
Ehud Lamm - Pyrex - A language for writing Python extension modules  blueArrow
4/20/2002; 9:13:01 AM (reads: 2942, responses: 3)
Pyrex - A language for writing Python extension modules
Pyrex is a language specially designed for writing Python extension modules. It's designed to bridge the gap between the nice, high-level, easy-to-use world of Python and the messy, low-level world of C...

Pyrex deals with the basic types just as easily as SWIG, but it also lets you write code to convert between arbitrary Python data structures and arbitrary C data structures, in a simple and natural way, without knowing anything about the Python/C API. That's right -- nothing at all! Nor do you have to worry about reference counting or error checking -- it's all taken care of automatically, behind the scenes, just as it is in interpreted Python code. And when fully implemented, Pyrex will let you define new built-in Python types just as easily as you can define new classes in Python.

The way this works is that you write code in a Python-like language (Pyrex), which allows you to access C data types directly, as well as standard Python data. The Pyrex code is then compiled into C.

Seems like a nice way to extend a language. Better than having to use a different language completely, as when writing extension modules in C or C++.

In some sense this is reminiscent of inlining and macros.


Posted to Python by Ehud Lamm on 4/20/02; 9:14:15 AM

scruzia - Re: Pyrex - A language for writing Python extension modules  blueArrow
4/20/2002; 11:23:55 AM (reads: 1521, responses: 0)
I wonder if anyone is working on a multi-level approach to FP, similar to what SGI's Pro64 compiler did with WHIRL, or what Pyrex programmers do, or Rice's PLT scheme does. See http://radio.weblogs.com/0100945/2002/04/20.html#a117

I picture it this way: you write your Haskell program, where Haskell's laziness, advanced type system, etc., allow you to develop the program more quickly than with most other kinds of systems. The performance of your program sucks. So you profile it and convert some of the hot spots into (something like Pyrex, but between Haskell and C). What would that something look like?

David B. Wildgoose - Re: Pyrex - A language for writing Python extension modules  blueArrow
4/21/2002; 2:37:26 PM (reads: 1501, responses: 0)
Nice Idea.

I realise that it is already possible to interface Haskell to C, but I suspect (as a Haskell newcomer) that the fit must be awkward when it comes to type safety.

Perhaps the single most pressing need is the ability to perform top-notch profiling of memory and CPU usage in order to best identify which functions need work.

Alex A. Naanou - Re: Pyrex - A language for writing Python extension modules  blueArrow
8/10/2002; 5:01:17 PM (reads: 1222, responses: 0)
Good Idea Indeed...

Though this is not haskell, nor is it blazingly fast, but it implements the good idea. gprolog (GNU Prolog) is an interesting prolog "dialect" with a multi-level implementation making it an interpreted and compiled language at the same time! with allot of tasty features. see:

http://sourceforge.net/projects/gprolog/

and

http://gnu-prolog.inria.fr/