Python idiom: hashing dict