Modules are hashable?!
Alex Martelli
aleaxit at yahoo.com
Wed Sep 1 07:26:22 EDT 2004
More information about the Python-list mailing list
Wed Sep 1 07:26:22 EDT 2004
- Previous message (by thread): Modules are hashable?!
- Next message (by thread): Modules are hashable?!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Leif K-Brooks <eurleif at ecritters.biz> wrote: > I was just playing around, and noticed that modules seem to be hashable. > Can anyone explain that, especially given the fact that they're mutable? Any object x is hashable if type(x) does not expose __eq__ nor __cmp__. In that case, the meaning of x==y for that object is 'x is y', that is, id(x)==id(y), so having hash(x) return id(x) is perfectly functional. Mutation is not a problem if it doesn't affect equality comparisons. Alex
- Previous message (by thread): Modules are hashable?!
- Next message (by thread): Modules are hashable?!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list