CodePy

CodePy

CodePy is a C/C++ metaprogramming toolkit for Python. It handles two aspects of native-code metaprogramming:

  • Generating C/C++ source code.
  • Compiling this source code and dynamically loading it into the Python interpreter.

Both capabilities are meant to be used together, but also work on their own. In particular, the code generation facilities work well in conjunction with PyCuda. Dynamic compilation and linking are so far only supported in Linux with the GNU toolchain.

Documentation

See the Manual.

Support

Having trouble with CodePy? Feel free to shoot me an email.

Download

CodePy may be downloaded from its Python Package Index page or obtained directly from my source code repository by typing

git clone http://git.tiker.net/trees/codepy.git

You may also browse the source.

CodePy has no prerequisites other than Python 2.4. Some additional functionality is available if Boost.Python is installed, which is part ofBoost C++ (any recent version should work).

CodePy: Initial public Release

I'm happy to announce the initial public release of CodePy, a native-code Metaprogramming toolkit for Python.

The idea is the following:

  • You build a string that is actually C code.
  • CodePy compiles it, links it, and dynamically loads it into the Python interpreter.

Ta-da: Instant native-code performance, with no explicit pre-compilation step. CodePy can also help you with the generation of the code, by letting you build a data structure and turning that into C code. CodePy works well with Boost.Python and PyCuda. In conjunction with the latter, it offers an easy way of doing GPU Metaprogramming, a very effective tuning technique for the GPU.