executablebooks / rst-to-myst

Convert ReStructuredText to MyST Markdown
https://rst-to-myst.readthedocs.io
MIT License
64 stars 11 forks source link

perf: cache ApplicationNamespaces #37

Closed zsol closed 1 year ago

zsol commented 2 years ago

Calling to_docutils_ast repeatedly results in calling compile_namespace every time, even if directives and roles don't change between invocations. compile_namespace is relatively expensive, especially when sphinx is involved. This commit memoizes compile_namespace for significant perf improvements.

codecov[bot] commented 1 year ago

Codecov Report

Base: 84.48% // Head: 84.50% // Increases project coverage by +0.01% :tada:

Coverage data is based on head (3ef3671) compared to base (c5c475e). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #37 +/- ## ========================================== + Coverage 84.48% 84.50% +0.01% ========================================== Files 10 10 Lines 1637 1639 +2 ========================================== + Hits 1383 1385 +2 Misses 254 254 ``` | Flag | Coverage Δ | | |---|---|---| | pytests | `84.50% <100.00%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/executablebooks/rst-to-myst/pull/37?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | Coverage Δ | | |---|---|---| | [rst\_to\_myst/cli.py](https://codecov.io/gh/executablebooks/rst-to-myst/pull/37/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#diff-cnN0X3RvX215c3QvY2xpLnB5) | `83.85% <100.00%> (ø)` | | | [rst\_to\_myst/namespace.py](https://codecov.io/gh/executablebooks/rst-to-myst/pull/37/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#diff-cnN0X3RvX215c3QvbmFtZXNwYWNlLnB5) | `77.14% <100.00%> (+0.33%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

chrisjsewell commented 1 year ago

Superceded by #46, hope thats ok thanks