表单: PythonNotes
用户: dreamable
创建日期: 2020-11-23 23:50:21 UTC
更新日期: 2020-12-02 23:47:54 UTC
引用:(Table ID 14, Record ID 1)

标题 :
cython
笔记 :
  1. python vs cpython vs cython

    • python: 语言
    • cpython: Python的解释器,用C实现的,也有用Java实现的Jython
    • cython:优化器,将python编译为C语言,提高运行速度
      • superset language
      • python + C extension
  2. install (version 0.29.21)

    sudo pip install cython
    
  3. setup.py

    from setuptools import setup
    from Cython.Build import cythonize
    setup(
    name='Hello world app',
    ext_modules=cythonize(["hello.py","utils.py","config.py"],annotate=True),
    zip_safe=False,
    )
    
    python setup.py build_ext --inplace
    
    • build error
    • in ~/engine: ERROR: error: [Errno 2] No such file or directory: 'engine/hello.so'
    • in ~/engine/tmp: OK
    • in `~/engine2': OK
    • remove __init__.py solves the problem.
标签: