提问者:小点点

有什么东西可以替代Python中的模运算符吗? [已关闭]


在python中处理大素数时,模运算符需要花费太多的时间来执行,有没有什么方法可以用更节省时间的方法来替换它? 代码:

def H1(id, choice):
id = str(id)
str2hash1 = id
result11 = hashlib.md5(str2hash1.encode())
result11.update((str(choice)).encode('utf-8'))
res11 = int(result11.hexdigest(), 16)
h1 = res11 % q
if (h1 % 2) == 1:
    h1 = h1 + 1
else:
    pass
return h1

共1个答案

匿名用户

如果您可以附加您的代码来查看实际问题在哪里,那么提供帮助会更容易。