Python中.pyx与.pyd

  • pyx

    PYX file is a Pyrex source.

    Pyrex is a Language for Writing Python Extension modules.

    Pyrex lets you write code that mixes Python and C data types any way you want, and compiles it into a C extension for Python.

    .pyx 文件是由 Cython 编程语言 “编写” 而成的 Python 扩展模块源代码文件。

    .pyx 文件类似于 C 语言的 .c 源代码文件,.pyx 文件中有 Cython 模块的源代码。

    不像 Python 语言可直接解释使用的 .py 文件,.pyx 文件必须先被编译成 .c 文件,再编译成 .pyd (Windows 平台) 或 .so (Linux 平台) 文件,才可作为模块 import 导入使用。

  • pyx相关扩展

    .py Python Script

    .pym Python Macro File

    .pyc Python Bytecode

    .pyd Python Dynamic Module

    .pyo Python Optimized Code

    .tcl TCL Script

    .pxd Pyrex Definition File

    .pyr Python Repository

    .pth Python Path Configuration

    .pxi Pyrex Include File

  • 如何创建pyx文件

  • pyd

    .pyd 文件是非Python,由其它编程语言 “编写-编译” 生成的 Python 扩展模块。

    .pyd是二进制文件,只能反编译查看,本质上就是DLL文件。

    Python 要导入 .pyd 文件,实际上是在 .pyd 文件中封装了一个 module。在 python 中使用时,把它当成 module 来用就可以了,即:"import 路径名.modulename" 即可,路径名为 .pyd 文件所在的路径。

  • References

  1. Cython - 基于 Pyrex 编写 Python 的 C 语言扩展模块的静态编译器

  2. PYX 文件扩展

  3. Python 的 .py 与 Cython 的 .pxd .pyx .pyd 文件格式之间的主要区别

  • 4
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值