Does Pickle always produce the same output for a certain input value? I suppose there could be a gotcha when pickling dictionaries that have the same contents but different insert/delete histories. My goal is to create a “signature” of function arguments, using Pickle and SHA1, for a memoize implementation.
Share
Right:
See also: pickle.dumps not suitable for hashing
There’s a number of fundamental problems with this. It’s impossible to come up with an object-to-string transformation that maps equality correctly—think of the problem of object identity:
Depending on your exact requirements, you may be able to transform object hierarchies into ones that you could then hash: