[Python-Dev] Deterministic builds of the interpreter

Armin Rigo armin.rigo at gmail.com
Sun Feb 19 03:30:47 EST 2017


Hi Freddy,

On 16 February 2017 at 18:03, Freddy Rietdijk <freddyrietdijk at fridh.nl> wrote:
> As I mentioned, it seems only sets cause unreproducible
> bytecode. Sets have no order. But when generating the bytecode, I would
> expect there would still be an order since the code isn't actually executed,
> right?

No, the sets are built as real sets and then marshalled to .pyc files
in a separate step.  So on CPython an essentially random order will
end up in the .pyc file.  Even CPython 3.6 gives a deterministic order
to dictionaries but not sets.  You could ensure sets are marshalled in
a known order by changing the marshalling code, e.g. to emit them in
sorted order (on Python 2.x; on 3.x it is more messy because different
types are more often non-comparable).


A bientôt,

Armin.


More information about the Python-Dev mailing list