从 Python 调用 C/C++? [英] Calling C/C++ from Python?

查看:42
本文介绍了从 Python 调用 C/C++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建到 C 或 C++ 库的 Python 绑定的最快方法是什么?

What would be the quickest way to construct a Python binding to a C or C++ library?

(如果这很重要,我使用的是 Windows.)

(I am using Windows if this matters.)

推荐答案

你应该看看 Boost.Python.这是他们网站上的简短介绍:

You should have a look at Boost.Python. Here is the short introduction taken from their website:

Boost Python 库是一个框架,用于连接 Python 和C++.它允许您快速无缝地公开 C++ 类函数和对象转换为 Python,反之亦然,无需特殊使用工具——只是你的 C++ 编译器.它旨在包装 C++ 接口非侵入式,因此您不必更改 C++ 代码一切都是为了包装它,使 Boost.Python 非常适合暴露Python 的第 3 方库.图书馆使用先进元编程技术为用户简化了它的语法,以便包装代码呈现出一种声明式接口的外观定义语言(IDL).

The Boost Python Library is a framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes functions and objects to Python, and vice-versa, using no special tools -- just your C++ compiler. It is designed to wrap C++ interfaces non-intrusively, so that you should not have to change the C++ code at all in order to wrap it, making Boost.Python ideal for exposing 3rd-party libraries to Python. The library's use of advanced metaprogramming techniques simplifies its syntax for users, so that wrapping code takes on the look of a kind of declarative interface definition language (IDL).

这篇关于从 Python 调用 C/C++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆