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.
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).
I have the same reaction as you. I am very impressed by this, as well as pybind11. My only worry is the fear that the automagic will break down somewhere, but I hope I am wrong and it will not hurt to try! If it works, it will significantly speed up my integration with an SDK that would have required enough extra hours to have otherwise not been worth it. Very exciting.
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.
4 comments
[ 2.7 ms ] story [ 22.4 ms ] threadHowever 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
https://github.com/bdarnell/codegenloader