Pyrex is a programming language that enables programmers to write Python extension modules.
At first, you might question why a specialized language is necessary for Python extension modules. After all, C or C++ can be used to extend Python. However, if you've ever written an extension module for Python, you'll know that things are not as straightforward as they appear. You have to write a lot of boilerplate code before you can even start working on your extension module. Moreover, you have to deal with the challenge of converting back and forth between Python and C data types, which can be exceedingly difficult for anything more elaborate than numeric and string representations. Plus, you must be incredibly scrupulous in maintaining reference counts and checking for errors if you want to avoid crashing your program.
While SWIG is a well-known tool that can ease the burden of producing extension code, it only generates pure-Python classes that wrap pointers to C data structures. If you want to create a new Python type or substantially restructure data between C and Python, you'll still need to use Python/C API calls. Similarly, PyInline allows developers to embed pieces of C code within Python files and then extracts and compiles them for extension modules. However, both SWIG and PyInline don't address the creation of new Python types, and they only automatically convert basic data types.
On the other hand, Pyrex aims to provide a much more comprehensive solution. Pyrex allows developers to convert between arbitrary Python and C data structures quickly, efficiently, and naturally without even requiring knowledge of the Python/C API. It handles reference counting and error checking automatically, eliminating the need to worry about crashes that are tough to debug. Not to mention, Pyrex even lets developers define new built-in Python types just as quickly and easily as defining new Python classes.
The latest release of Pyrex has just a minor bugfix that addresses a tab/space problem in the distutils extension. Overall, Pyrex's unique features make it an excellent and highly recommended tool for developing Python extension modules without the hassle and potential crashes of other methods.
Version 0.9.4.1: N/A