Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy initialise registry #37

Open
lewisjared opened this issue Sep 27, 2022 · 1 comment
Open

Lazy initialise registry #37

lewisjared opened this issue Sep 27, 2022 · 1 comment

Comments

@lewisjared
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Currently a default unit registry is instantiated on import. This takes 1s even if no unit ops are performed. For CLI operations this can make things sluggish.

Describe the solution you'd like

The unit registry is lazily initialised when the first unit operation is needed. ScmUnitRegistry would become a proxy to the underlying registry and control the initialisation.

Describe alternatives you've considered

Remove openscm_units.unit_registry.

@znicholls
Copy link
Contributor

Sounds good. We currently lazy initialise the contexts so should also be possible with units...

I'm also still not sure if we're using pint correctly. At the moment, our custom transformations have to be defined from and to everything so pint's internal map is huge. I don't think that's how it works for SI units so maybe there's a possible optimisation there too.

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

No branches or pull requests

2 participants