Skip to content

Bypass conversion computation when units strings match#173

Merged
kroenlein merged 1 commit intomainfrom
feature/same-units-speedup
Aug 17, 2022
Merged

Bypass conversion computation when units strings match#173
kroenlein merged 1 commit intomainfrom
feature/same-units-speedup

Conversation

@kroenlein
Copy link
Copy Markdown
Collaborator

Profiling showed some downstream applications are bottle-necked by no-op unit transformations. This PR adds an early exit when the unit strings are equal.

@kroenlein kroenlein requested a review from sfriedowitz August 17, 2022 20:20
Copy link
Copy Markdown

@sfriedowitz sfriedowitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

with _change_units(filename=pkg_resources.resource_filename("gemd.units",
"tests/test_units.txt")):
with pytest.raises(UndefinedUnitError):
assert convert_units(1, 'm', 'cm') == 100
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@kroenlein kroenlein merged commit a7c717b into main Aug 17, 2022
@kroenlein kroenlein deleted the feature/same-units-speedup branch April 19, 2023 16:21
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