~/talk

No time to idle about: Profiling import time in Python

Talkat PyCon AU 2019 · 2019-08-02..08-06· [python, web-performance]
links:none on file
slides:none on file

Python 3.7 exposes per-module timings via the -X importtime runtime flag and that data can be parsed, turned into a tree/graph, and visualised with flamegraph/tuner SVGs to reveal that a single import can dominate startup (examples show ~11s and a 10× gap). A small Python wrapper reproduces similar timing on 3.4–3.6, pydeps is extended to show import times and connectedness, and a combined metric (time, number of importers, unique attribute access) picks actionable targets for fixes like lazy imports or lazy instantiation which measurably reduce CLI startup.

AI-written summary · about

  1. 0:00Introduction
  2. 1:25The problem
  3. 3:36Different approaches
  4. 6:45The hack
  5. 8:04Visualization
  6. 10:30Tuner
  7. 11:23Is import a tree
  8. 13:29Paid EPS
  9. 17:14Node size
  10. 19:18Unique attribute access
  11. 21:19Improvements
  12. 24:42Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.