Cython is an open source programming language created in 2007.
#165on PLDB | 17Years Old | 698Repos |
Cython is a superset of the Python programming language, designed to give C-like performance with code which is mostly written in Python. Cython is a compiled language that generates CPython extension modules. These extension modules can then be loaded and used by regular Python code using the import statement. Read more on Wikipedia...
In [1]: %load_ext Cython
In [2]: %%cython
...: def f(n):
...: a = 0
...: for i in range(n):
...: a += i
...: return a
...:
...: cpdef g(int n):
...: cdef int a = 0, i
...: for i in range(n):
...: a += i
...: return a
...:
In [3]: %timeit f(1000000)
42.7 ms ± 783 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [4]: %timeit g(1000000)
74 µs ± 16.6 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
Feature | Supported | Example | Token |
---|---|---|---|
Integers | ✓ | ||
Floats | ✓ | ||
Hexadecimals | ✓ | ||
Octals | ✓ |