Speed up Python2 nested loops with XOR

后端 未结 3 2118
死守一世寂寞
死守一世寂寞 2020-12-22 12:44

The answer of the question this is marked duplicate of is wrong and does not satisfy my needs.

My code aims to calculate a hash from a seri

3条回答
  •  半阙折子戏
    2020-12-22 13:40

    It looks like you can replace the inner loop and if with:

    for j in range(length - i) val^=start+c c+=1 c+=i This should save some time when i gets bigger

    I'm afraid I can't test this right now, sorry!

提交回复
热议问题