MSE-seminar: Program Analysis and Transformation, 2011
The C/C++ metaprogramming toolkit for Python , CodePy , is analysed according to its source code generation possibility and its way to generate extension modules for Python. The combination of both results in generating C code in a Python script and executing it from within the same script. Insights are given on how this roundtrip is achieved using the Boost Python  library. It is outlined why Boost Python simplifies this roundtrip and with Instant Python  another toolkit is introduced that also enables to call a C function that is former described in a Python string. The analysis of the code generation capability of CodePy includes a comparison of the syntax tree building approach, as CodePy’s way to describe the target code, with the approach of using the Mako  template engine. The advantages of Python in combination with machine code compiled libraries are outlined as well as the advantages of code generation at runtime. With PyCUDA  a project is introduced which makes use of these advantages by combining Python and CUDA , and it is shown how CodePy can be used in conjunction with PyCUDA.
January 6, 2012 by hgpu