官术网_书友最值得收藏!

Preface

Cython is a tool that makes writing native extensions to Python as easy as writing them in Python. For those who are unaware, you can implement Python modules as pure the C code, which will, for all intents and purposes, look and act like any Python code. This is required when implementing modules in Python, such as the built-in zip module which use native zlib under the hood. Doing this makes sense for the standard library modules part of Python, though for most users of Python, writing native modules should be the last course of action if possible.

Writing native modules is hard and requires prerequisite knowledge of how to use the garbage collector calls correctly in order to avoid memory leaks. It also requires an understanding of how the GIL is used, which changes if you are using CPython or PyPy. It also requires knowledge of the module structures and argument passing internally to the Python runtime. Therefore, it isn't a trivial process when the need arises. Cython lets us write and work with the native code without having to know anything about the Python runtime. We can write almost pure Python code that just so happens to let us manipulate C/C++ types and classes. We can call back and forth from the native code and into the Python code.

More importantly, Cython removes the complexity and intrinsicity and lets the programmer focus on solving problems.

主站蜘蛛池模板: 方山县| 大渡口区| 乌什县| 五河县| 来安县| 桦南县| 柯坪县| 荆州市| 阿尔山市| 军事| 定州市| 潢川县| 涞源县| 东乡县| 曲麻莱县| 赣州市| 罗江县| 五指山市| 鄂尔多斯市| 泾阳县| 贡山| 光泽县| 忻城县| 康乐县| 历史| 南和县| 哈尔滨市| 禹城市| 怀化市| 大足县| 阳信县| 扬州市| 云南省| 马公市| 阜新| 喀喇| 夏河县| 宁乡县| 五河县| 邢台市| 承德市|