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

Rework: new convert() API, higher performance, remember preferred unit exactly #3

Merged
merged 16 commits into from
Mar 19, 2024

Conversation

bradenmacdonald
Copy link
Owner

This PR is a fairly significant refactor that:

  • greatly improves performance (it now beats all other libraries on the benchmark)
  • adds a new .convert() API so you can convert to your preferred unit while still getting a Quantity object. The previous .getWithUnits() API for conversions did not return a Quantity object, so was less useful.
  • To achieve the improved performance, the (internal) concept of "unit hints" has been replaced with "output unit". This means that each Quantity instance remembers what units it was initialized with, and will use those as the default output unit. (Previously only the "hint" of what unit to use was remembered, and this required more computation at each step to determine the actual exact unit to use).
  • Removed the unused luminosity and angle dimensions. Just left one unused placeholder dimension for now. You can still add as many custom dimensions as you want.

@bradenmacdonald bradenmacdonald merged commit 860c848 into main Mar 19, 2024
1 check passed
@bradenmacdonald bradenmacdonald deleted the rework branch March 19, 2024 06:31
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.

1 participant