Introduction to Cython

version: 3.0.0a10

Overview

Cython is a programming language that makes writing C/C++ extensions for the Python language as easy as Python itself. The source code gets translated into optimized C/C++ code and compiled as Python extension modules. This allows for both very fast program execution and tight integration with external C libraries, while keeping up the high programmer productivity for which the Python language is well known.

Type declarations can therefore be used for two purposes: for moving code sections from dynamic Python semantics into static-and-fast C semantics, but also for directly manipulating types defined in external libraries.

Installing Cython

Unlike most Python software, Cython requires a C compiler to be present on the system. The details of getting a C compiler varies according to the system used:

  • Linux
    • The GNU C Compiler (gcc) is usually present
    • sudo apt-get install build-essential python3-dev
  • Mac OS X
    • To retrieve gcc, one option is to install Apple’s XCode
    • https://developer.apple.com/
  • Windows
    • Microsoft Visual C/C++ (MSVC)
    • https://wiki.python.org/moin/WindowsCompilers.

The simplest way of installing Cython is by using pip:

pip install Cython==3.0.0a10

Building Cython Code

Cython code must, unlike Python, be compiled. The general procedure for compiling Cython can now be described as follows:

  • .pyx
  • .pyd
  • setup.py
  • (optional) .c/.cpp & .h/.hpp

ref.

http://docs.cython.org/en/latest/

2022

Stack

1 minute read

Introduction

Stack

less than 1 minute read

Introduction

Download-only-one-directory

less than 1 minute read

Git 명령어를 사용한 하위 디렉토리 다운로드 Clone 할 로컬 저장소 생성

Sort

3 minute read

Introduction

Tree

less than 1 minute read

Introduction

Mutex library on C++

less than 1 minute read

#include <iostream> #include <thread> #include <chrono> #include <mutex> #include <atomic> #include <string.h>

TODO

less than 1 minute read

how to costom github blog using jekyll

Welcome to Jekyll!

less than 1 minute read

You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different wa...

Back to top ↑