python - Is it a good idea to generate and store a random number as a hash value for my class? -


i have class wraps list, , lists apparently can't have hash values. idea generate random number , store hash value.

not idea. general contract of hash code if object equals object b, a.hashcode() equals b.hashcode(). you're proposing wont hold.

you try using

  • list length hash code
  • hash code of first item in list hashcode
  • sum of hashcodes of items hashcode

or else along these lines.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -