Why is hash() slower under python3.4 vs python2.7

前端 未结 1 1531
感动是毒
感动是毒 2021-01-13 06:13

I was doing some performance evaluation using timeit and discovered a performance degredation between python 2.7.10 and python 3.4.3. I narrowed it down to the hash()<

相关标签:
1条回答
  • 2021-01-13 06:25

    There are two changes in hash() function between Python 2.7 and Python 3.4

    1. Adoptions of SipHash
    2. Default enabling of Hash randomization

    References:

    • Since from Python 3.4, it uses SipHash for it's hashing function. Read: Python adopts SipHash
    • Since Python 3.3 Hash randomization is enabled by default. Reference: object.__hash__ (last line of this section). Specifying PYTHONHASHSEED the value 0 will disable hash randomization.
    0 讨论(0)
提交回复
热议问题