back.pysim: fix simulation of Value.xor().

This commit is contained in:
whitequark 2019-09-20 10:12:59 +00:00
parent 4777a7b3a2
commit 7f6b3f93f5
2 changed files with 6 additions and 3 deletions

View file

@ -137,7 +137,7 @@ class _RHSValueCompiler(_ValueCompiler):
return lambda state: normalize(arg(state) == mask, shape)
if value.op == "r^":
# Believe it or not, this is the fastest way to compute a sideways XOR in Python.
return lambda state: normalize(str(arg(state)).count("1") % 2, shape)
return lambda state: normalize(format(arg(state), "b").count("1") % 2, shape)
elif len(value.operands) == 2:
lhs, rhs = map(self, value.operands)
if value.op == "+":