OverflowError
Python int too large to convert to C long
File "H:\spinal code cloud\程序\spinal codes_ver3.7_an\A_Lookup3.py", line 17, in lookup3Init
lookup3array = np.array([0xdeadbeef + val] * 3, dtype=np.uint32)
File "H:\spinal code cloud\程序\spinal codes_ver3.7_an\A_Hash.py", line 29, in hash_func
hash_state = lookup3Init(s)
File "H:\spinal code cloud\程序\spinal codes_ver3.7_an\A_Encoder.py", line 80, in init
spine_value = hash_func(spine_value, block)
File "H:\spinal code cloud\程序\spinal codes_ver3.7_an\A_Spinal.py", line 82, in
encoder = Encoder(k, map_func, message)
def lookup3Init(val):
lookup3array = np.array([0xdeadbeef + val] * 3, dtype=np.uint32) #这里有问题
lookup3list = list(lookup3array)
return lookup3list
def lookup3Update(state, data):
def rot(x,k):
return (((x) << (k)) | ((x) >> (32-(k)))) #
state[1] += data
state[2] ^= state[1] #这里有问题
state[2] -= rot(state[1],14)
state[0] ^= state[2]
state[0] -= rot(state[2],11)
state[1] ^= state[0]
state[1] -= rot(state[0],25)
state[2] ^= state[1]
state[2] -= rot(state[1],16)
state[0] ^= state[2]
state[0] -= rot(state[2],4)
state[1] ^= state[0]
state[1] -= rot(state[0],14)
state[2] ^= state[1]
state[2] -= rot(state[1],24)
return state
state[2] ^= state[1]
state[1] * state[2]的值太大,超过了int可以表示的范围
一、[0xdeadbeef + val] * 3,这个乘以3是不是已经溢出了,你把0xdeadbeef换成一个比较小的数试试
二、或者把dtype=np.uint32改成dtype=np.float64,或者更大的数据类型试试。
三、更新成python3.4,参考https://bugs.python.org/issue21816