Skip to content

runtime: compile the standard library bytecode - #87

Merged
eunomie merged 1 commit into
mainfrom
python-sdk-stdlib-bytecode
Nov 10, 2026
Merged

eunomie merged 1 commit into
mainfrom
python-sdk-stdlib-bytecode

Conversation

@eunomie

@eunomie eunomie commented Nov 9, 2026

Copy link
Copy Markdown
Member

Base images ship the standard library without most of its bytecode, and a call's writes do not last, so each Python module call recompiled what it imports. The runtime build now compiles the interpreter's standard library once, checked-hash, in a layer on the base image alone (below uv and module inputs), so modules on the same base share it.

Measured (beta.25 engine, warm, five fresh leaf calls, Python 3.14.8, python:3.14-slim; median span):

function exec
before 637.7 ms 573.2 ms
after 374.1 ms 308.7 ms

First build pays about 1.2 s once for the compile exec.

Checks: runtime-call-check and runtime-scope-install-check pass on beta.25. Not run: the other e2e checks and the floor-engine checks.

Known limits:

  • Best effort: only python on PATH is compiled; a custom image without it, or with a read-only standard library, still builds.
  • Through the generated entrypoint the engine keys every exec on the module's source, so a source edit recompiles once (about 1.2 s, cached afterwards), as the dependency install already does. The new e2e assertion covers the runtime path only.

Signed-off-by: Yves Brissaud <yves@dagger.io>
@eunomie
eunomie marked this pull request as ready for review November 10, 2026 06:37
@eunomie
eunomie merged commit b738845 into main Nov 10, 2026
68 checks passed
@eunomie
eunomie deleted the python-sdk-stdlib-bytecode branch November 10, 2026 14:05
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.

1 participant