Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Mutable objects can't be hashed right?


As the comment you responded to says: An object can be mutable and hashable. E.g. any custom class by default has mutable and hashable instances.


How can you get both mutable and hashable instances at the same time?


the only requirement on a hashable instance is that it implements a proper __hash__ function. The default implementation in CPython returns the address of the memory the object is stored at, so all instances are considered unique, values play no role at all.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: