GeezerVison is showing github.com — gh-118761: Improve import time of `tomllib` by hukkin · Pull Request #128907 · python/cpython
Conversation
hukkin
commented
Jan 16, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
This is a port of two commits in Tomli repository (the diff of these commits being hukkin/tomli@42a570d...1da01ef).
This removes runtime overhead of string, typing, and tomllib._types imports from import tomllib.
main branch
$ hyperfine --warmup 8 "./python -c 'import tomllib'" "./python -c 'pass'"
Benchmark 1: ./python -c 'import tomllib'
Time (mean ± σ): 70.3 ms ± 1.8 ms [User: 66.0 ms, System: 4.3 ms]
Range (min … max): 68.6 ms … 76.8 ms 41 runs
Benchmark 2: ./python -c 'pass'
Time (mean ± σ): 26.2 ms ± 0.7 ms [User: 23.3 ms, System: 3.0 ms]
Range (min … max): 25.1 ms … 29.7 ms 110 runs
Summary
'./python -c 'pass'' ran
2.69 ± 0.10 times faster than './python -c 'import tomllib''
PR branch
$ hyperfine --warmup 8 "./python -c 'import tomllib'" "./python -c 'pass'"
Benchmark 1: ./python -c 'import tomllib'
Time (mean ± σ): 48.0 ms ± 0.7 ms [User: 43.4 ms, System: 4.7 ms]
Range (min … max): 46.8 ms … 50.2 ms 60 runs
Benchmark 2: ./python -c 'pass'
Time (mean ± σ): 26.1 ms ± 0.4 ms [User: 23.5 ms, System: 2.7 ms]
Range (min … max): 25.3 ms … 27.4 ms 110 runs
Summary
'./python -c 'pass'' ran
1.84 ± 0.04 times faster than './python -c 'import tomllib''
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
AA-Turner reacted with hooray emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
cc @encukou who added the module in Python 3.11 (PEP 680).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
gpshead
gpshead approved these changes
encukou
Awaiting requested review from encukou
encukou is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|