如何在C中创建Python类?
16lz
2021-01-22
I have a legacy C library that creates a tree of objects. I would like to convert the tree into a pre-existing Python class. How do I create the PyObject for that class?
我有一个遗留的C库,可以创建一个对象树。我想将树转换为预先存在的Python类。如何为该类创建PyObject?
3 个解决方案
#1
Cython is capable of doing this. It's a semi-fork of Pyrex, and it can wrap existing data structures and expose them to Python. In fact, this is one of the sections in the user guide. Cython is relatively easy to use, and it includes an HTML-output format that shows all the generated code as well as highlighted hot spots where optimization could be applied.
Cython能够做到这一点。它是Pyrex的半分支,它可以包装现有的数据结构并将它们暴露给Python。实际上,这是用户指南中的一个部分。 Cython相对易于使用,它包含一个HTML输出格式,显示所有生成的代码以及可以应用优化的突出显示的热点。
更多相关文章
- 《数据结构与算法Python语言描述》裘宗燕 笔记 第五章 栈和队列
- Linux内核数据结构之链表
- java数据结构--链表
- 数据结构:关于重建二叉树的三种思路
- “树”不倒,人不散—数据结构的核心
- 如何使用Thymleaf做到这一点?
- 数据结构学习----线性表(Java版的实现)
- java入门---数据结构操作实例之获取链表的元素
- 数据结构-java与c实现带头结点的单链表