Python: how does a dict with mixed key type work? -


i understand following valid in python: foo = {'a': 0, 1: 2, some_obj: 'c'}

however, wonder how internal works. treat (object, string, number, etc.) object? type check determine how compute hash code given key?

types aren't used same way in python statically types languages. hashable object 1 valid hash method. interpreter calls method, no type checking or anything. there on out, standard hash map principles apply: object fulfill contract, must implement both hash , equals methods.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -