FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-118761: Improve import time of `tomllib` by hukkin · Pull Request #128907 · python/cpython · GitHub

/ cpython Public

gh-118761: Improve import time of tomllib - #128907

Merged
gpshead merged 1 commit into
python:mainfrom
hukkin:tomllib-importtime
Jan 17, 2025
Merged

gh-118761: Improve import time of tomllib#128907
gpshead merged 1 commit into
python:mainfrom
hukkin:tomllib-importtime

Conversation

hukkin commented Jan 16, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

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''

Comment thread Lib/tomllib/_parser.py
Comment thread Lib/tomllib/_parser.py

Copy link
Copy Markdown
Member

cc @encukou who added the module in Python 3.11 (PEP 680).

gpshead merged commit ea6cc26 into python:main Jan 17, 2025
hukkin deleted the tomllib-importtime branch January 17, 2025 05:47

encukou commented Jan 17, 2025

Copy link
Copy Markdown
Member

Thank you!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

6 participants


Back | FazBrowse Home | New Git URL