开发者

PyPy C/API access

开发者 https://www.devze.com 2023-03-20 02:59 出处:网络
I\'ve been looking through the reference docs and can\'t find any mention of a C API for PyPy. Does it exist? If so is 开发者_StackOverflow中文版it the same as the CPython C API? If PyPy was run on to

I've been looking through the reference docs and can't find any mention of a C API for PyPy. Does it exist? If so is 开发者_StackOverflow中文版it the same as the CPython C API? If PyPy was run on top of CPython would it change this?


PyPy has alpha-level support for the CPython extension API via an emulation layer called CPyExt. Here's a blog post introducing the support; here's a later one discussing it. If your goal is to interface with a C library, you're probably best off just writing a Python wrapper module that uses ctypes to call into it.

Running PyPy on CPython wouldn't help (besides slowing things down terribly), because the API wouldn't interact with PyPy's object model—it would interact with that of the CPython host environment.

0

精彩评论

暂无评论...
验证码 换一张
取 消