Description
Hi again!
As we know, hash(x)
in python yields different values across different interpreter sessions for security. It turns out that I am using attrs in all of my class definitions in a library and would like to bootstrap off of the programmatically generated hash
function to essentially create a merkle tree. I would like to use hashlib.md5()
or something similar and create a digest using all the attributes attrs can find in the class so that:
- the hash is consistent across runs.
- less importantly for me, but maybe more importantly for others, using a better hash allows for less collisions.
As always, please let me know if this is something attrs can/cannot support, and I will work with/around it accordingly. Thanks!
P.S. My workaround would be to define my own function to find all attributes using attr.asdict()
and then creating a hash that way. Not terrible, but I figured it'd be worth asking for a "purer" solution.