For anyone looking for a more usable version of C++/Python interop, I can't recommend Cppyy[0] highly enough. You can use any C++ code/libraries from Python without the need to write any bindings. I created an example project here to test it out[1].<p>0. <a href="https://cppyy.readthedocs.io/en/latest/" rel="nofollow">https://cppyy.readthedocs.io/en/latest/</a><p>1. <a href="https://github.com/jclay/cppyy-knearestneighbors-example" rel="nofollow">https://github.com/jclay/cppyy-knearestneighbors-example</a>
> The exact same Python++ file can be fed in unmodified to a stock C++ compiler and a stock Python interpreter and you will get the same output. The first version of Python++ was developed by William W Wold for the Stupid Shit No One Needs and Terrible Ideas Hackathon 2017.<p>Sounds about right, but it is very impressive.
This is really clever! Here's a more traditional approach that I stumbled across:<p><a href="https://github.com/lukasmartinelli/py14" rel="nofollow">https://github.com/lukasmartinelli/py14</a><p>It translates a small subset of Python to C++ 14.<p>I'm going to attempt this for real pretty soon on my shell project :) Although I'm using MyPy rather than relying on type inference.<p>MyPy is useful and solid now!
If anyone seriously want to write a program that works equally in Python and C++, use Haxe, which compiles to a few more targets as well: JavaScript, Java, C#, C (HashLink), Lua etc.<p>Haxe isn't a polyglot, but a compiled language though.
All I really want is a minimum effort way to map C++ libraries to Python in a way that supports Numpy and is not tied to a Python version. CFFI is close, but it could be even more ergonomic. Build scripts can generate everything else automatically, outside Numpy functions.