
Import C++ files directly from Python - ratneshmadaan
https://github.com/tbenthompson/cppimport
======
bdarnell
If you like cross-language import hacks like this then you might be interested
in my codegenloader package, which lets you import .proto or .thrift files
directly (and it's extensible for other code generators). Mine is a little
less magical since it needs to be declared in the package where it will be
used, instead of affecting all imports everywhere.

[https://github.com/bdarnell/codegenloader](https://github.com/bdarnell/codegenloader)

------
versteegen
Very nice! This seems more convenient than using Cython glue code. But how on
Earth had I not heard of pybind11, the magic library that this is built on?
It's just what I wanted: boost::python without boost.

~~~
dr_zoidberg
When I read it, it remind me of Cython's pyximport:

    
    
        >>> import pyximport; pyximport.install()
        >>> import helloworld
        Hello World
    

The example is taken from Cython's basic tutorial page[0], in which
helloworld.pyx simply has a print "Hello World" statement.

However I don't don't Cython and cppimport are interchangeable, or that using
one excludes using the other. cppimport is for bringing C++ code in a seamless
way, while Cython makes it easy to optimize Python code converting it to C
(which you can further hand optimize if you so need it).

[0]
[http://docs.cython.org/src/tutorial/cython_tutorial.html](http://docs.cython.org/src/tutorial/cython_tutorial.html)

