%%cython

def f1():
    # 2 bytes
    cdef short x = 1
    return x

def f2():
    # 4 bytes
    cdef int x = 1
    return x

def f3():
    # 4 or 8 bytes, depends on your OS
    cdef long x = 1
    return x

def f4():
    # 8 bytes
    cdef long long x = 1
    return x

print(type(f1()))
print(type(f2()))
print(type(f3()))
print(type(f4()))

"""
Explanation: Return integers to Python (no problems)
End of explanation
"""


# Biggest unsigned short, 2 bytes => 16 bits
print(2**16 - 1)
# Biggest unsigned int, 4 bytes => 32 bits
print(2**32 - 1)
# Biggest unsigned long long, 8 bytes => 64 bits
print(2**64 - 1)

"""
Explanation: (How to calculate max integers)
End of explanation
"""


%%cython

cpdef can_handle_ushort(unsigned short x):
    return x

cpdef can_handle_uint(unsigned int x):
    return x

cpdef can_handle_ulong_long(unsigned long long x):
    return x

can_handle_ushort(2**16-1)

can_handle_ushort(2**16)

can_handle_uint(2**32-1)

can_handle_uint(2**32)

can_handle_ulong_long(2**64-1)

can_handle_ulong_long(2**64)

"""
Explanation: Getting integers from Python (ouch!)
Python can handle very big numbers.  Be careful passing big numbers into Cython functions.
End of explanation
"""


