Cython

Cython(サイソン)は、C言語によるPythonの拡張モジュールの作成の労力を軽減することを目的として開発されたプログラ…

Cython
Cython
作者 Robert Bradshaw、Stefan Behnel など
初版 2007年7月28日 (19年前) (2007-07-28)[1]
最新版
3.1.1[2] / 2025年5月19日 (15か月前) (2025-05-19)
リポジトリ ウィキデータを編集
プログラミング
言語
C言語, Python
対応OS Windows, macOS, Linux
プラットフォーム クロスプラットフォーム
ライセンス Apache License 2.0
公式サイト cython.org ウィキデータを編集
テンプレートを表示

Cython(サイソン)は、C言語によるPythonの拡張モジュールの作成の労力を軽減することを目的として開発されたプログラミング言語である。その言語仕様はほとんどPythonのものと同じ (上位互換) だが、Cの関数を直接呼び出したり、C言語の変数の型やクラスを宣言できるなどの拡張が行われている。Cythonの処理系ではソースファイルをCのコードに変換し、コンパイルすればPythonの拡張モジュールになるようにして出力する。

このようにCとPythonをシームレスに取り混ぜて扱うCythonの利点の一つは、既にあるPythonコードを、いくつかの静的な型 (static type) を宣言して律速なループをうまく書き直すだけで、コンパイル後のコードの実行速度がC言語並みに高速化されることである。複雑なC言語インターフェイスを使う必要はない。コーディングのしやすさと可読性はPythonと変わらない、つまりPythonic英語版なままである。数値計算/配列操作では、多くの場合実行速度がおおよそ100倍になる。PythonのJITコンパイラであるPsycoの場合はおおよそ4倍である。

CythonはPyrex言語から派生したもので、Pyrexに比べると様々な機能や高度な最適化が加えられている。

自由ソフトウェアの数値計算・数式処理システムであるSAGEの一部はCythonで書かれている。

Cythonの処理系はPythonで書かれており、WindowsLinuxmacOSで実行できる。

脚注

関連項目

参考

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.