Hi:

EXPY (http://expy.sourceforge.net/) is an express way to extend Python. 

Why consider expy? Here are some good reasons:

(I). WYSIWYG. The expy project enables you to write your module in Python the 
way your extension would be (WYSIWYG), and meanwhile write your implementation 
in pure C. You specify your modules, functions, methods, classes, and even 
their documentations the usual way of writing your Python correspondences. Then 
provide your implementation to the functions/methods by returning a multi-line 
string. By such an arrangement, everything falls in its right place, and your 
extension code becomes easy to read and maintain. Also, the generated code is 
very human-friendly.

(II). You only provide minimal information to indicate your intension of how 
your module/class would function in Python. So your extension is largely 
independent from the Python extension API. As your interaction with the Python 
extension API is reduced to minimal (you only care about the functionality and 
logic), it is then possible that your module written in expy can be independent 
of changes in the extension API.

(III). The building and setup of your project can be automatically done with 
the distutil tool. In the tutorial, there are ample examples on how easily this 
is achieved.

(IV). Very light weight. The expy tool is surprisingly light weight dispite of 
its powerful ability, as it is written in pure Python. There is no parser or 
compiler for code generation, but rather the powerful reflexion mechanism of 
Python is exploited in a clever way to generate human-friendly codes. 
Currently, generating code in C is supported, however, the implementation is 
well modularized and code generation in other languages such as Java and C++ 
should be easy.

Currently, EXPY/CXPY works with Python 2.5, 2.6. I haven’t tested with Python 
2.7 or 3.x (for 3.x, need to use the code tool first, and I am not sure if the 
C API for 3.x has changed much, if you happen to try it out, let me know what 
happened).

While there are already a couple of other projects trying to simply this task 
with different strategies, such as Cython, Pyrex and modulator, this project is 
unique and charming in its own way. All you need is the WYSIWYG Python file for 
your module extension, then expy takes care of everything else. What follows in 
this documentation is on how to extend Python in C using expy-cxpy: the module 
expy helps define your module, while module cxpy helps generate C codes for 
your defined module.

Yingjie


      
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to