Python 3.7+ to Cython CheatSheet by examples as simple as posible, because I cant find a Cython Cheatsheet on Internet.
It start with simple stuff and continues towards more complex ones, is compatible with PXD that allows to left the *.py untouched.
All values and variable names are example values.
Python (Medium Integers)
a = 1Cython (Medium Integers)
cdef int a
a = 1var a = 1Nim can make it explicit int32() if you want, but is not needed.
Python (Big Integers)
a = 1000000000000000000Cython (Big Integers)
cdef longlong a
a = 1000000000000000000var a = 1000000000000000000Nim can make it explicit int64() if you want, but is not needed.
Python
a = "foo"Cython
cdef char* a
a = "foo"var a = "foo"Python (Small Floats)
a = 1.0Cython (Small Floats)
cdef double a
a = 1.0var a = 1.0Python (Medium Floats)
a = 1.000001Cython (Medium Floats)
cdef long double a
a = 1.000001var a = 1.000001Python (Big Floats)
a = 1.0000000001Cython (Big Floats)
cdef longlong double a
a = 1.0000000001var a = 1.0000000001Python
a = TrueCython
cdef bint a
a = Truevar a = truePython
def foo(bar: str, baz: bool) -> int:
    return 1Cython
cdef int foo(char bar, bint baz)proc foo(bar: string, baz: bool): int =
    return 1Python
def foo(self, bar: str, baz: bool) -> int:
    return 1Cython
cdef int foo(self, char bar, bint baz)proc foo(self: ObjectHere, bar: string, baz: bool): int =
    return 1Python
from typing import Callable
variable: Callable[[int, int], int] = lambda var1, var2: var1 + var2( proc(var1, var2: int): int = var1 + var2 )Python Lambdas are not supported on Cython. Documentation is missing on Cython.
For Python you are forced to put it on a variable for Type Annotations, Nim anonymous functions are Typed by itself.
Python Lambda syntax is different, Nim anonymous functions are just functions without name.
Python
class MyObject(object):
  """ Documentation String """
  passCython
type MyObject = object  ## Documentation StringPython
# This is a comment
""" This is a DocString, plain-text by default """Cython
# This is a comment
""" This is a DocString, plain-text by default, but Cython itself dont take care about them, you need third party tool """# This is a comment
## This is a Documentation Comment, **MarkDown** or *ReSTructuredText*, can generate HTML, LaTex, JSON documentation by itself, no third party tool requiredNimpy puts Documentation Comments on the __doc__ as expected.
What about classes?