Skip to content

compileall isn't reproducible #161434

Closed as duplicate
Closed as duplicate

Description

@rossburton

Bug report

If you repeatedly run python3 -mcompileall -f over the standard library, the generated .pyc files are not reproducible. I'm explicitly using the hash-based invalidation mode to avoid time stamps.

My reproducer is a copy of stdlib put into a git repo, then I delete .pyc files and regenerate them in a loop with:

$ python3 -mcompileall --invalidation-mode checked-hash  pystdlib -f

With some repeating, and especially when using -j, I get different files. Interestingly, it's often the same files that change...

For example:

diff --git i/__pycache__/functools.cpython-314.pyc w/__pycache__/functools.cpython-314.pyc
index 506a7ba..ec11d46 100644
--- i/__pycache__/functools.cpython-314.pyc
+++ w/__pycache__/functools.cpython-314.pyc
@@ -441,12 +441,12 @@
 00001b80  52 05 17 00 6c 08 74 08  56 01 33 01 52 06 17 00  |R...l.t.V.3.R...|
 00001b90  6c 08 74 09 56 01 33 01  52 07 17 00 6c 08 74 0a  |l.t.V.3.R...l.t.|
 00001ba0  52 08 74 0b 52 09 74 0c  56 00 74 0d 52 08 23 00  |R.t.R.t.V.t.R.#.|
-00001bb0  29 0a da 15 63 6d 70 5f  74 6f 5f 6b 65 79 2e 3c  |)...cmp_to_key.<|
+00001bb0  29 0a 7a 15 63 6d 70 5f  74 6f 5f 6b 65 79 2e 3c  |).z.cmp_to_key.<|
 00001bc0  6c 6f 63 61 6c 73 3e 2e  4b da 03 6f 62 6a 63 02  |locals>.K..objc.|
 00001bd0  00 00 00 00 00 00 00 00  00 00 00 02 00 00 00 13  |................|
 00001be0  00 00 08 f3 12 00 00 00  80 00 57 10 6e 00 00 00  |..........W.n...|
 00001bf0  00 00 00 00 00 00 52 00  23 00 a9 01 4e a9 01 72  |......R.#...N..r|
-00001c00  5c 00 00 00 29 02 72 27  00 00 00 72 5c 00 00 00  |\...).r'...r\...|
+00001c00  5b 00 00 00 29 02 72 27  00 00 00 72 5b 00 00 00  |[...).r'...r[...|
 00001c10  73 02 00 00 00 26 26 72  1b 00 00 00 da 08 5f 5f  |s....&&r......__|
 00001c20  69 6e 69 74 5f 5f da 1e  63 6d 70 5f 74 6f 5f 6b  |init__..cmp_to_k|
 00001c30  65 79 2e 3c 6c 6f 63 61  6c 73 3e 2e 4b 2e 5f 5f  |ey.<locals>.K.__|
@@ -458,7 +458,7 @@
[snip]

I've attached these two .pyc files in case anyone can read pyc and identify what the difference is.

functools.zip

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Activity

  1. aisk commented on Nov 5, 2026

    @aisk
    Member

    Thank you for reporting, but I think this is a duplicate of #129724, which has been fixed on main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions