News for hackers. Stuff that matters.
Re:Python overtakes JavaScript as most questioned language o... by BurningFrog on Saturday April 20, 2019 @11:39AM (#19707089)
Yeah, I don't actually know if Python computes hashes for dicts by content or "identity".

I just assumed it was the former, based on the fact that dicts are disallowed as keys.

Re:Python overtakes JavaScript as most questioned language o... by fiddlerwoaroof on Saturday April 20, 2019 @01:26PM (#19707689)
It’s been a while, but I’m pretty sure the reason why a dictionary can’t have a dictionary as it’s key is because the dictionary class doesn’t implement the __hash__ method that would compute the hashcode.
Re:Python overtakes JavaScript as most questioned language o... by np_tedious on Sunday April 21, 2019 @06:34AM (#19711464)
This is definitely the proximate reason.

The reason for that choice is because the object is mutable.

Re:Python overtakes JavaScript as most questioned language o... by fiddlerwoaroof on Sunday April 21, 2019 @02:39PM (#19713724)
Sure, but as others have mentioned, you can make your own choice by subclassing dict and defining your own hash function, as long as that function is defined in a way that follows the appropriate rules.