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
|
|