TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A framework for creating Python/C++ polyglots

110 点作者 mnem大约 6 年前

6 条评论

jclay大约 6 年前
For anyone looking for a more usable version of C++&#x2F;Python interop, I can&#x27;t recommend Cppyy[0] highly enough. You can use any C++ code&#x2F;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:&#x2F;&#x2F;cppyy.readthedocs.io&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cppyy.readthedocs.io&#x2F;en&#x2F;latest&#x2F;</a><p>1. <a href="https:&#x2F;&#x2F;github.com&#x2F;jclay&#x2F;cppyy-knearestneighbors-example" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jclay&#x2F;cppyy-knearestneighbors-example</a>
评论 #19336026 未加载
评论 #19335579 未加载
评论 #19336033 未加载
评论 #19334860 未加载
评论 #19334359 未加载
OceanKing大约 6 年前
&gt; 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.
评论 #19334267 未加载
评论 #19334395 未加载
chubot大约 6 年前
This is really clever! Here&#x27;s a more traditional approach that I stumbled across:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;lukasmartinelli&#x2F;py14" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lukasmartinelli&#x2F;py14</a><p>It translates a small subset of Python to C++ 14.<p>I&#x27;m going to attempt this for real pretty soon on my shell project :) Although I&#x27;m using MyPy rather than relying on type inference.<p>MyPy is useful and solid now!
andyonthewings大约 6 年前
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&#x27;t a polyglot, but a compiled language though.
127大约 6 年前
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大约 6 年前
I like Pybind.