金子邦彦研究室プログラミングPythoncython を使ってみる

cython を使ってみる

関連する外部ページ

http://omake.accense.com/static/doc-ja/cython/src/userguide/tutorial.html

前準備

Python の準備(Windows,Ubuntu 上)

サイト内の関連ページ

関連する外部ページ

Python の公式ページ: https://www.python.org/

Python のまとめ: 別ページ »にまとめ

Python の公式ページ: https://www.python.org/

cython を使うプログラム例

  1. cython のインストール
    python -m pip install cython
    

  2. helloworld.pyx
    print "Hello World"
    

  3. setup.py
    from distutils.core import setup
    from distutils.extension import Extension
    from Cython.Distutils import build_ext
    
    setup(
        cmdclass = {'build_ext': build_ext},
        ext_modules = [Extension("helloworld", ["helloworld.pyx"])]
    )
    
  4. ライブラリファイルの作成
    python setup.py build_ext --inplace
    

    [image]