11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OSXでのCython実行方法メモ

Last updated at Posted at 2013-10-15

##OSXでのCython実行方法メモ

###セットアップファイルを用意する。

filename_setup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#filename_setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext as build_pyx
setup(name = 'filename', ext_modules=[Extension('filename', ['filename.pyx'])], cmdclass = { 'build_ext': build_pyx })

###Terminalでセットアップファイルをビルドする。

$ cp filename.py filename.pyx
$ Cython filename.pyx
$ python filename_setup.py build
$ python

#ちなみに上記のCython前にpyx内にてcdef使って変数の型を指定してあげるとより一層速くなる。

###Pythonでインポートする。

>> import pyximport; pyximport.install()
>> import filename

簡単でそ

Cython: C-Extensions for Python

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?