Extensions for Python

本文介绍了如何创建Python扩展,主要涉及使用C/C++编写应用代码,通过boilerplates进行包装,以及编译和测试过程。详细步骤包括:1) 编写C/C++代码并实现Python接口;2) 包装代码,包含Python头文件,编写Python模块函数的wrapper,定义模块方法数组及初始化函数;3) 使用distutils创建setup.py文件编译扩展,并将生成的pyd文件复制到Python的DLLs目录下以便导入和测试。通过一个简单的hello世界示例,展示了Python扩展的具体实现过程。
摘要由CSDN通过智能技术生成

备注:这里是我为培训写的PPT,网上资料较少,特此分享出来。

  

What is python extension?

    The extension of python is that provided by other computer language such as C/C++.

    Creating extensions for python involves three main steps:

      1. Creating application code

      2. Wrapping code with boilerplates

      3. Compilation and testing

 

      1. Creating application code

         To call c function in python, we need program codes inherit corresponding wraps interface,and then Complier them as a pythons module.

 

      2. Wrapping code with boilerplates

      1). Include Python header file

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值