
A framework for creating Python/C++ polyglots - mnem
https://github.com/wmww/Python-plus-plus
======
jclay
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].

0\.
[https://cppyy.readthedocs.io/en/latest/](https://cppyy.readthedocs.io/en/latest/)

1\. [https://github.com/jclay/cppyy-knearestneighbors-
example](https://github.com/jclay/cppyy-knearestneighbors-example)

~~~
mbeex
From your second link:

" Note: I'm using Python 2

This is because even the latest clang-python in Debian (for clang 6) provides
Python 2 bindings only. "

Is this still true?

~~~
jclay
I believe it's no longer the case. The maintainer of Cppyy was cautioning that
the Python 3 support was somewhat experimental at the time, but I believe it's
officially supported now. Either way, it could have been solved by building
from source, but I was feeling lazy :)

------
OceanKing
> 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.

Sounds about right, but it is very impressive.

~~~
svnpenn
Came here for this. At least they are self aware.

------
chubot
This is really clever! Here's a more traditional approach that I stumbled
across:

[https://github.com/lukasmartinelli/py14](https://github.com/lukasmartinelli/py14)

It translates a small subset of Python to C++ 14.

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.

MyPy is useful and solid now!

------
andyonthewings
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.

Haxe isn't a polyglot, but a compiled language though.

------
127
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.

------
adamnemecek
I like Pybind.

