Skip to content

Commit 33f16ba

Browse files
speed-up Structure instantiation (#4415)
Signed-off-by: Daniel Zügner <[email protected]>
1 parent 24cd680 commit 33f16ba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pymatgen/core/periodic_table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def __eq__(self, other: object) -> bool:
236236

237237
def __hash__(self) -> int:
238238
# multiply Z by 1000 to avoid hash collisions of element N with isotopes of elements N+/-1,2,3...
239-
return self.Z * 1000 + self.A if self._is_named_isotope else self.Z
239+
return self.Z * 1000 + self.A if self._is_named_isotope else self.Z * 137 * 100
240240

241241
def __repr__(self) -> str:
242242
return f"Element {self.symbol}"
@@ -1605,7 +1605,7 @@ def get_el_sp(obj: SpeciesLike) -> Element | Species | DummySpecies:
16051605
pass
16061606

16071607

1608-
@functools.lru_cache
1608+
@functools.lru_cache(maxsize=1024)
16091609
def get_el_sp(obj: int | SpeciesLike) -> Element | Species | DummySpecies:
16101610
"""Utility function to get an Element, Species or DummySpecies from any input.
16111611

0 commit comments

Comments
 (0)