Skip to content

Improve speed of quantity stringification #2090

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

Merged
merged 2 commits into from
Jul 23, 2025

Conversation

mattwthompson
Copy link
Member

Relates to #2065, split off from #2081

I see a ~20% speedup in stringifying some force fields

In [1]: import openff.toolkit

In [2]: ff14sb = openff.toolkit.ForceField("ff14sb_off_impropers_0.0.4.offxml")
/Users/mattthompson/micromamba/envs/openff-toolkit-test/lib/python3.12/site-packages/openff/amber_ff_ports/amber_ff_ports.py:8: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  from pkg_resources import resource_filename
/Users/mattthompson/micromamba/envs/openff-toolkit-test/lib/python3.12/site-packages/openff/amber_ff_ports/amber_ff_ports.py:8: UserWarning: Module openff was already imported from None, but /Users/mattthompson/software/openff-toolkit is being added to sys.path
  from pkg_resources import resource_filename

In [3]: %timeit ff14sb._to_smirnoff_data()
388 ms ± 2.91 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

This is compared to

501 ms ± 24.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

upstream, on my machine

Copy link

codecov bot commented Jul 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.61%. Comparing base (158117d) to head (a3a6010).
Report is 1 commits behind head on main.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mattwthompson mattwthompson marked this pull request as ready for review July 22, 2025 15:31
@mattwthompson mattwthompson requested a review from j-wags as a code owner July 22, 2025 15:31
@j-wags j-wags self-assigned this Jul 22, 2025
Copy link
Member

@j-wags j-wags left a comment

Choose a reason for hiding this comment

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

Glorious, contender for best PR of the year. Please update releasenotes before merging to claim some credit :-)

@mattwthompson mattwthompson merged commit 2bf586e into main Jul 23, 2025
17 checks passed
@mattwthompson mattwthompson deleted the faster-quantity-to-string branch July 23, 2025 16:20
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