Cython

Sophie·2022년 8월 1일
0

python

목록 보기
1/3

cython 사용 방법

https://cython.readthedocs.io/en/latest/src/quickstart/build.html

  1. 기존 코드 작성 및 확장자 .pyx로 설정
  2. 아래 코드를 가진 python 파일생성
from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules=cythonize("[FILE_NAME].pyx", compiler_directives={'language_level': 3})
)
  1. 콘솔에서 실행
python setup.py build_ext --inplace

  1. 해당 pyx파일 import 하여 사용
import [FILE_NAME]

  • 근데 그냥 py파일을 1번 코드에 실행 시 c파일이 만들어짐(??) 이건 그냥 c로 만들어준건걸지..?
profile
Now or Never

0개의 댓글