V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
saxon
V2EX  ›  Python

py 与 C Py 与 C++的混写

  •  
  •   saxon ·
    saxon17 · 2015-07-20 14:10:37 +08:00 · 3151 次点击
    这是一个创建于 3195 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Py如何调用C 和C++的函数、类
    问题也可以反过来
    求指教

    11 条回复    2015-09-14 13:11:52 +08:00
    wynemo
        1
    wynemo  
       2015-07-20 16:23:43 +08:00
    boost python
    wynemo
        2
    wynemo  
       2015-07-20 16:27:39 +08:00
    paw
        3
    paw  
       2015-07-20 16:38:52 +08:00
    ctypes.CDLL 加载C/C++编写的动态链接库
    反过来 不知道。。。没用过
    nooper
        4
    nooper  
       2015-07-20 16:39:59 +08:00
    我写过。可以用cython,swig,boost python。如果简单的就用 简单的方式。
    clino
        5
    clino  
       2015-07-20 16:41:13 +08:00
    @nooper cython是不是这三个里最简单的?
    nooper
        6
    nooper  
       2015-07-20 16:41:54 +08:00
    @clino 不一定看需求。关键是难度和对C++和理解。
    mozartgho
        7
    mozartgho  
       2015-07-20 17:13:15 +08:00
    C/C++中调用Python,就是把Python虚拟机集成到程序中,然后把Python的C API封装下给C++程序调用;Python使用C/C++程序写的扩展,需要把C程序编译成动态库,然后在Python中直接import扩展模块,当然C/C++写扩展需要一定的要求,具体看Python文档。
    janxin
        9
    janxin  
       2015-07-20 19:46:24 +08:00
    相对来说C/C++里用Python会更容易一点,C++的DLL和C的DLL对Python区别挺大
    saxon
        10
    saxon  
    OP
       2015-07-21 19:30:03 +08:00
    @wynemo
    @nooper
    @xanpeng
    @mozartgho
    @janxin 就不一 一感谢了~~ 谢谢热心的回答
    saxon
        11
    saxon  
    OP
       2015-09-14 13:11:52 +08:00 via iPhone
    @xanpeng 谢谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5726 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 02:14 · PVG 10:14 · LAX 19:14 · JFK 22:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.