Skip to content

Efficiency updates for __str__() methods#4446

Merged
shyuep merged 1 commit intomaterialsproject:masterfrom
kavanase:species_str_speedup
Jul 3, 2025
Merged

Efficiency updates for __str__() methods#4446
shyuep merged 1 commit intomaterialsproject:masterfrom
kavanase:species_str_speedup

Conversation

@kavanase
Copy link
Contributor

@kavanase kavanase commented Jul 3, 2025

Small change to improve the efficiency of Species.__str__, which can become a bottleneck in some workflows which e.g. subselect sites in a structure based on the species, before doing further processing (e.g. defect site matching in doped).

Improves efficiency by reducing redundant getattr calls.

@kavanase kavanase requested review from mkhorton and shyuep as code owners July 3, 2025 02:45
@kavanase
Copy link
Contributor Author

kavanase commented Jul 3, 2025

The one failing test is an import timing test, which I believe is separate to any changes in this PR

Failed: from pymatgen.core.trajectory import Trajectory import too slow at 607.46 ms! hard_threshold=600.91 ms

@shyuep shyuep merged commit f9d9fe8 into materialsproject:master Jul 3, 2025
43 of 44 checks passed
@shyuep
Copy link
Member

shyuep commented Jul 3, 2025

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants