[cfe-dev] C++ to Python Project Proposal

Luc Bourhis luc_j_bourhis at mac.com
Fri Nov 5 14:54:01 PDT 2010


> I would like to use Clang to take many C++ classes and wrap them with the Boost::Python for use with python code.

My 2 pennies but the project would be much more interesting if you planned to directly output CPython code. 

Indeed Boost.Python is a fantastic tool plagued by a fatal flaw: the size of the compiled extensions eventually produced is humongous. For example, I have a library that weights ~500K to be compared with the 2.2 Mo of the corresponding Boost.Python binding. There are several project out there that tries to address that issue (pybindgen, Shiboken) but they are all limited by the tool they use to parse C++ headers, pygccxml for pybindgen, which makes it a no-go on Windows, and hand-roled parsers for Shiboken, which will never ever reach the quality and completeness of Clang.

Clang opens immense opportunities here. Not only to solve that problem but also to revolutionise the subject. A compiler could be built that would on the one hand compile the C++ code as usual, and on the other hand read some special #pragmas or special instructions in comments and then build in memory the Python binding code, and then compile it on the flag, and link it into a shared library.

Luc Bourhis
 



More information about the cfe-dev mailing list