Skip to content

Instantly share code, notes, and snippets.

View mengcz13's full-sized avatar
💭
I may be slow to respond.

Chuizheng Meng mengcz13

💭
I may be slow to respond.
View GitHub Profile
@ctokheim
ctokheim / cython_tricks.md
Last active March 4, 2024 23:27
cython tricks

Cython

Cython has two major benefits:

  1. Making python code faster, particularly things that can't be done in scipy/numpy
  2. Wrapping/interfacing with C/C++ code

Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.