update int hash

This commit is contained in:
blueloveTH 2024-11-23 16:43:06 +08:00
parent 620db020ed
commit 0a75eb857c
2 changed files with 11 additions and 3 deletions

View File

@ -244,9 +244,7 @@ static py_i64 c11_8bytes__hash(union c11_8bytes u) {
static bool int__hash__(int argc, py_Ref argv) {
PY_CHECK_ARGC(1);
py_i64 val = py_toint(&argv[0]);
union c11_8bytes u = {._i64 = val};
py_newint(py_retval(), c11_8bytes__hash(u));
py_assign(py_retval(), argv);
return true;
}

View File

@ -138,3 +138,13 @@ for i in range(n):
# if i % 3 == 0:
# y = b.pop()
# delattr(a, y)
d = {}
for i in range(-1000, 1000):
d[i] = i
assert d[i] == i
e = {}
for i in range(-10000, 10000, 3):
e[i] = i
assert e[i] == i