Using pickle.dumps to hash mutable objects

前端 未结 1 1351
臣服心动
臣服心动 2020-12-22 03:09

I understand why putting mutable objects in a dictionary is dangerous. However, converting all lists/sets to tuples/frozensets is expensive; and for many types, there\'s no

相关标签:
1条回答
  • 2020-12-22 03:45

    The output from pickle is not guaranteed to be canonical for similar reasons to dict and set order being non-deterministic. Don't use pickle or pprint or repr for hashing.

    0 讨论(0)
提交回复
热议问题