Pyrex (programming language)

Pyrex is a programming language developed to aid in creating Python modules. Its syntax is very close to Python. The goal is to make it easy for Python programmers to write the non-Python supporting code usually required for interfacing modules in a language which is as close to Python as possible.

Pyrex
Developer(s)Greg Ewing
Initial release3 April 2002 (2002-04-03)[1]
Stable release
0.9.9 / 12 April 2010 (2010-04-12)
Written inPython, C
Operating systemCross-platform
TypeProgramming language
Websitewww.cosc.canterbury.ac.nz/~greg/python/Pyrex/

Python limitation

Python itself only provides a C API to write extension modules, which allows writing of functions and datatypes in C. These can then be accessed from Python. It is thus also possible to wrap the functions and datatypes of existing C libraries as Python objects and therefore make them available to Python.

Other tools

There are tools like SWIG or Python's foreign function library ctypes which can be used for this task without requiring much additional code, but this is limited to making an external library available in Python code. If adjustments to the API are needed, glue code must again be written manually. This is where Pyrex fits in.

Pyrex abilities

Pyrex allows the user to write extension modules in a Python-like language which may directly access the external C code. The similarity of Pyrex's syntax to Python's makes it easy to write Python modules, as there is no need to learn another language (such as C or C++), and there may be no need to write any glue code. All that is needed is to specify the name of C-header files, enumerations, datatypes and functions needing to be accessed in the module. Then one simply uses them as if they were Python objects. The Pyrex compiler will generate the necessary glue code automatically and compile the Pyrex code into a working Python module.

gollark: Regular SATA ports?
gollark: Postgres is good.
gollark: What? Why?
gollark: Just hardcode every single possible page.
gollark: Why pjals? WHY?

See also

  • Cython, a derivative of Pyrex.

References

  1. greg at cosc (April 3, 2002). "ANN: Pyrex - a language for writing Python extension modules". Retrieved February 24, 2014.


This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.