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
yangzh
V2EX  ›  Python

python 调用 c 大家都用啥?

  •  
  •   yangzh · 2015-06-07 14:34:23 +08:00 via iPhone · 5121 次点击
    这是一个创建于 3217 天前的主题,其中的信息可能已经有所发展或是发生改变。
    常见的似乎有 cython ctypes 等。最近发现 pypy 项目组有个 cffi 项目好像比较优雅,但是中文资源非常少。
    7 条回复    2015-06-13 11:46:45 +08:00
    ruoyu0088
        1
    ruoyu0088  
       2015-06-07 16:03:14 +08:00 via Android
    我都是一起用,先cffi, 比较特殊的用法用ctypes,例如获取全局变量的地址。提速用cython,例如在循环中调用函数。
    baka
        2
    baka  
       2015-06-07 16:04:13 +08:00
    ctypes
    lilydjwg
        3
    lilydjwg  
       2015-06-07 16:25:37 +08:00   ❤️ 2
    简单的用 ctypes,复杂的用 cffi 或者 cython 或者 Python C API。

    cffi 不需要太多文档呀。我用过 LuaJIT FFI,那边的经验到 cffi 这边基本可用。
    nabla
        4
    nabla  
       2015-06-07 19:23:33 +08:00
    之前用过SWIG来生成wrapper,感觉还可以
    xxer
        5
    xxer  
       2015-06-07 21:55:57 +08:00
    @baka +1
    mathgl
        6
    mathgl  
       2015-06-08 13:11:39 +08:00
    use cffi first, if need c++ support, use cython.
    zhuangzhuang1988
        7
    zhuangzhuang1988  
       2015-06-13 11:46:45 +08:00
    Boost.Python
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3254 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 11:48 · PVG 19:48 · LAX 04:48 · JFK 07:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.