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

Immutable constants for symbolic dimensions #60

Open
MilesCranmer opened this issue Oct 14, 2023 · 0 comments
Open

Immutable constants for symbolic dimensions #60

MilesCranmer opened this issue Oct 14, 2023 · 0 comments

Comments

@MilesCranmer
Copy link
Member

MilesCranmer commented Oct 14, 2023

Right now the units and constants for symbolic dimensions, like the one you get from us"km", are stored with mutable arrays (note that non-symbolic versions like u"km" are fine as-is).

This is part of the reason it takes so long to generate all of the constants, which is why they are created at first call to sym_uparse, rather than at precompilation time. This is why the first time you call us"km", it takes a little longer. It's also why you can't precompile things with symbolic dimensions (see #58).

I think it might make sense instead to have an immutable version of each of the symbolic units and constants. I'm not quite sure how this would work. Maybe you could have another SymbolicImmutableDimensions <: AbstractDimensions that is explicitly for storing symbolic dimensions constants, and stores the symbol.

Then you could have promotion rules set up so it will convert itself to SymbolicDimensions when operated on. But maybe there is a simpler way.

Thoughts @gaurav-arya @devmotion?

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

1 participant