Bytecode compilation output depends on order of files compiled #129724
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-feature
A feature request or enhancement
Bug report
Bug description:
This is minimal reproduction of this downstream bug report: astral-sh/uv#10619
The output of
compileall.compile_file
depends on the order in which the files are compiled. This means compilation is non-deterministic if builds are distributed over a process pool.This becomes a problem when building docker images, where you usually bytecode compile ahead of time for faster startup, and where the hash of the image depends on all files in the image, including the
.pyc
files.Specifically, the output of
is different if we previously compiled another file with
Reproducer script:
This is caused be different refcounts in the marshalled files:
This prints
2
and3
.The original report is from 3.13, i've reproduced it with 3.14.0a4. It happens at least on linux and windows.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: