Skip to content

Conversation

akx
Copy link
Contributor

@akx akx commented Jan 25, 2022

On my machine, this saves 33 milliseconds off import time for the library, which could be significant for e.g. CLI applications.

(master) $ hyperfine 'python -m markdown' Benchmark 1: python -m markdown Time (mean ± σ): 113.1 ms ± 11.5 ms [User: 84.8 ms, System: 19.2 ms] Range (min … max): 100.1 ms … 151.7 ms 19 runs (late-extensions) $ hyperfine 'python -m markdown' Benchmark 1: python -m markdown Time (mean ± σ): 80.7 ms ± 4.7 ms [User: 61.0 ms, System: 13.1 ms] Range (min … max): 73.9 ms … 94.8 ms 30 runs 

There is also a small benefit to the overall test suite run time:

(master) $ hyperfine 'python -m unittest discover tests' Benchmark 1: python -m unittest discover tests Time (mean ± σ): 1.177 s ± 0.074 s [User: 1.073 s, System: 0.051 s] Range (min … max): 1.075 s … 1.250 s 10 runs late-extensions) $ hyperfine 'python -m unittest discover tests' Benchmark 1: python -m unittest discover tests Time (mean ± σ): 1.085 s ± 0.029 s [User: 0.990 s, System: 0.046 s] Range (min … max): 1.034 s … 1.127 s 10 runs 

Going forward, one could consider making the importlib.metadata backport an optional dependency – it's only required if one wants to load an extension by name.

On my machine, this saves 33 milliseconds off import time for the library. ``` (master) $ hyperfine 'python -m markdown' Benchmark 1: python -m markdown Time (mean ± σ): 113.1 ms ± 11.5 ms [User: 84.8 ms, System: 19.2 ms] Range (min … max): 100.1 ms … 151.7 ms 19 runs (late-extensions) $ hyperfine 'python -m markdown' Benchmark 1: python -m markdown Time (mean ± σ): 80.7 ms ± 4.7 ms [User: 61.0 ms, System: 13.1 ms] Range (min … max): 73.9 ms … 94.8 ms 30 runs ```
@waylan waylan added the requires-changes Awaiting updates after a review. label Jan 25, 2022
@waylan waylan added this to the Version 3.4 milestone May 5, 2022
@waylan
Copy link
Member

waylan commented May 5, 2022

I will merge this if a note is added to the release notes.

@waylan waylan merged commit e958ec4 into Python-Markdown:master May 24, 2022
@waylan waylan added approved The pull request is ready to be merged. and removed requires-changes Awaiting updates after a review. labels May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved The pull request is ready to be merged.
2 participants