-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
Generally speaking one should look up an event by its id. Otherwise we'll fall back to `object.__hash__` (the instance's address, under CPython) which is probably not what you want. Noticed in #15240.
I suppose an alternative would be to use the event ID as the hash since we assume they're unique anyway? |
Yeah, I mulled over that but erred towards being more militant. This synapse/synapse/storage/databases/main/events.py Lines 1353 to 1367 in 2b78981
I suppose this might be an unnecessary change. The footgun I have in mind is
More generally EventBase feels like it might be mutable, so shouldn't be hashable? It just smells like a bug to me, but maybe I'm overreacting? |
I think they aren't really mutable but I'm honestly not sure? I think @erikjohnston had a branch somewhere that did magic to ensure only a single copy ever existed per event. |
I think the unsigned and internal_metadata fields are mutable |
@DMRobertson Any idea if we should continue down this? |
I think that
is still a possibility, but looking back I'm not sure that making them unhashable is the right thing to do. I think let's drop this. |
See also #14911 which notes that we cache some |
Generally speaking one should look up an event by its id. Otherwise we'll fall back to
object.__hash__
(the instance's address, under CPython) which is probably not what you want.Noticed in #15240.