Closed paulromano closed 2 months ago
I rather see a deprecation of these, and force people that want direct access to use mendeleev.elements.H
instead of just mendeleev.H
.
Nice idea with the lazy loading, does it only work with dot access or also when importing with from mendeleev import Li
?
If it's the latter I think I would rather allow for sth like:
from mendeleev.elements import H, O, Fe
or
from mendeleev.elements import *
Few more places worth updating:
from mendeleev import H
The lazy loading works with either dot access or the from mendeleev import ...
form. I'll go ahead and update this to require the import specifically from mendeleev.elements
and update docs/tests accordingly.
I added a few adjustments, mostly catching up the latest changes on master and appeasing the linter.
Here's my quick attempt to reduce the overall import time by deferring the autoload of element data until one actually accesses the corresponding attribute from the
mendeleev
module, e.g.mendeleev.Li
. This seems to work pretty well in my limited testing. The only downside I can see is that the attribute names (H
,He
, etc.) won't show up in an autocomplete from an IDE. @lmmentel Let me know what you think of this approach.Fixes #118
Import timing
master
branch (python3.12):Import timing
current
branch (python3.12):On average this amounts to 7X speedup of import time.