Hynek Schlawack 11/20/2017

Python Hashes and Equality

Read Original

This technical article delves into Python's equality (__eq__) and hashing (__hash__) mechanisms. It explains common pitfalls when customizing these methods, emphasizing the rule that an object's hash must remain constant during its lifetime. The article illustrates the consequences of mutable hashes with code examples involving dictionaries and sets, highlighting subtle bugs that can occur.

Python Hashes and Equality

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week