roniemartinez / latex2mathml

Pure Python library for LaTeX to MathML conversion
MIT License
183 stars 25 forks source link

Remove usage of pkg_resources #359

Closed felixonmars closed 1 year ago

felixonmars commented 1 year ago

pkg_resources is expensive to load, which takes more than 400ms here.

Let's use importlib.metadata from stdlib for Python 3.8+, and fallback to importlib_metadata for Python 3.7.

Note that setuptools was a missing runtime dependency before this change.

This accelerates startup time significantly:

Before:

$ time latex2mathml -V
latex2mathml 3.73.1

real    0m0.728s
user    0m0.607s
sys     0m0.113s

After:

$ time latex2mathml -V
latex2mathml 3.73.1

real    0m0.156s
user    0m0.121s
sys     0m0.037s
codecov[bot] commented 1 year ago

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:

Coverage data is based on head (fc18bdb) compared to base (60b9563). Patch has no changes to coverable lines.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #359 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 6 6 Lines 925 925 ========================================= Hits 925 925 ``` | [Impacted Files](https://codecov.io/gh/roniemartinez/latex2mathml/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ronie+Martinez) | Coverage Δ | | |---|---|---| | [latex2mathml/converter.py](https://codecov.io/gh/roniemartinez/latex2mathml/pull/359/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ronie+Martinez#diff-bGF0ZXgybWF0aG1sL2NvbnZlcnRlci5weQ==) | `100.00% <ø> (ø)` | | 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=Ronie+Martinez). 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=Ronie+Martinez)

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