python 3.4, windows 10, cython 0.21.1
I'm compiling this function to c with cython
def weakchecksum(data):
"""
Generates a weak checksum from an iterable set of bytes.
"""
cdef long a, b, l
a = b = 0
l = len(data)
for i in range(l):
a += data[i]
b += (l - i)*data[i]
return (b << 16) | a, a, b
which produces this error: "OverflowError: Python int too large to convert to C long"
I've also tried declaring them as unsigned longs. What type do I use to work with really large numbers? If it's too large for a c long are there any workarounds?
cdef long long
?define LLONG_MAX 9223372036854775807LL
see gnu.org/software/libc/manual/html_node/…; unsigned long long is bigger. Yes, saw you are on windows but this should really bit about how many bits fit into hardware-level algorithms.