Why doesn't Python hash function give the same values when run on Android implementation?

前端 未结 5 731
-上瘾入骨i
-上瘾入骨i 2020-12-09 15:44

I believed that hash() function works the same in all python interpreters. But it differs when I run it on my mobile using python for android. I get same hash v

5条回答
  •  孤街浪徒
    2020-12-09 16:14

    Hashing of things like int relies on id(), which is not guaranteed constant between runs or between interpreters. That is, hash(int) will always produce the same result during a program's run, but might not compare equal between runs, either on the same platform or on different platforms.

    BTW, while hash randomization is available in Python, it's disabled by default. Since your strings and numbers are hashing equally, clearly it's not the issue here.

提交回复
热议问题