Cythonを使ってみるリンク

Cythonを使ってpythonを高速化するときのメモと参考リンク
Cythonファイル(test.pyx)をコンパイルするときはsetup.pyというファイルを作って以下の様に書く

from distutils.core import setup
from Cython.Build import cythonize
import numpy as np

setup(
		name = 'C extension module example',
		ext_modules = cythonize('test.pyx'),
		include_dirs = [np.get_include()]
		)

include_dirs = [np.get_include()]はtest.pyxの中でnumpyを使う時に必要らしい
コンパイルは以下の様にする

> python setup.py build_ext --inplace

以下、参考URL
http://docs.cython.org/src/tutorial/cython_tutorial.html#the-basics-of-cython
http://d.hatena.ne.jp/gumilab/20101109/1289310291
http://kesin.hatenablog.com/entry/20120314/1331689014