-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Improve tomllib startup time #147991
Copy link
Copy link
Open
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Metadata
Metadata
Assignees
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Currently, importing
tomllibtakes 9.5 ms. I wrote a proof-of-concept which defers importing regular expressions: with this change, importingtomllibnow only takes 0.9 ms (10.6x faster).Benchmark on Python built in release mode (
gcc -O3) on Fedora 43:With my change:
This optimization is motivated by PEP 829: Structured Startup Configuration via .site.toml Files discussion which proposes using
tomllibat Python startup.Linked PRs