mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
Core: Remove Location.__hash__ (#4274)
`Location` does not override `__eq__` so should not override `__hash__`. With this patch, this makes operations on sets of locations slightly faster because they will use `object.__hash__` rather than `Location.__hash__`. `object.__hash__` is about 4 to 5 times faster than `Location.__hash__` for me. Generation often uses sets of locations, so this slightly speeds up generation. The only place I could find that was hashing locations directly was `WitnessLocationHint.__hash__`, but it has implemented a matching `__eq__`, so is fine. For security reasons, Python randomizes its hash seed each time it is started, so the result of the `hash()` function is nondeterministic and can't have been used by worlds for anything that needed to be deterministic and can't have been used to compare information hashed at generation time to information hashed by a client.
This commit is contained in:
@@ -1313,9 +1313,6 @@ class Location:
|
||||
multiworld = self.parent_region.multiworld if self.parent_region and self.parent_region.multiworld else None
|
||||
return multiworld.get_name_string_for_object(self) if multiworld else f'{self.name} (Player {self.player})'
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.name, self.player))
|
||||
|
||||
def __lt__(self, other: Location):
|
||||
return (self.player, self.name) < (other.player, other.name)
|
||||
|
||||
|
Reference in New Issue
Block a user