Skip to content

Commit fb3aba1

Browse files
committed
Hash Term by tuple of variable pointers
hash(iteration) isn't fixed value
1 parent 81a0dc0 commit fb3aba1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/pyscipopt/expr.pxi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ cdef class Term:
108108

109109
def __init__(self, *vartuple: Variable):
110110
self.vartuple = tuple(sorted(vartuple, key=lambda v: v.getIndex()))
111-
self.hashval = <Py_ssize_t>hash(v.ptr() for v in self.vartuple)
111+
self.hashval = <Py_ssize_t>hash(tuple(v.ptr() for v in self.vartuple))
112112

113113
def __getitem__(self, idx):
114114
return self.vartuple[idx]
@@ -171,7 +171,7 @@ cdef class Term:
171171

172172
cdef Term res = Term.__new__(Term)
173173
res.vartuple = tuple(vartuple)
174-
res.hashval = <Py_ssize_t>hash(v.ptr() for v in res.vartuple)
174+
res.hashval = <Py_ssize_t>hash(tuple(v.ptr() for v in res.vartuple))
175175
return res
176176

177177
def __repr__(self):

0 commit comments

Comments
 (0)