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.


See the Manual.


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


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

git clone

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