Cython

Introduction

Cython is an optimising static compiler for both the Python programming language and the extended Cython programming language (based on Pyrex). It makes writing C/C++ extensions for Python as easy as Python itself.

Basic file type

  • hello.h
  • hello.c
  • hello.pyx
  • hello.pyd
  • makefile

.pyx and .pyd

  • .pyx文件是由Cython编写的Python扩展模块源代码文件,其内容支持C和python的语法。
  • .pyx文件类似于.c,.pyx文件必须先被编译成.c文件,再编译成.pyd(Windows平台)或.so(Linux平台)文件,才可作为模块import导入使用。
  • .pyd文件是非 Python,由其它编程语言编写,编译生成的Python扩展模块。
  • Python要导入.pyd文件,实际上是在.pyd文件中封装了一个module。在python中使用时,把它当成module来用就可以了。
  • Cython可将个人基于Python语言编写的Python模块编译成具有C语言特性的.pyd 文件。

Reference

Cython’s Documentation

recent article

Tmux

IntroductionTmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.Installatio...…

ubuntu screen tmux blogread
previous article

tf.scan()

explain the tf.scan() in detailOfficial API for explaining the tf.scan().definitiontf.scan( fn, elems, initializer=None, parallel_iterations=10, back_prop=True, swap_memory=False, infer_shape=True, name=None)examplesimport ...…

computer vision tensorflow scan blogread