Source: cython
Version: 0.23.2+git16-ga8fbae1-1
Severity: wishlist
Tags: patch
User: [email protected]
Usertags: randomness toolchain
X-Debbugs-Cc: [email protected]
Hi,
Whilst working on the "reproducible builds" effort [0], we noticed that
cython generates output that is not reproducible.
The attached patch removes non-deterministic dict ordering from the
output. Once applied, some packages that use cython can be built
reproducibly using our reproducible toolchain (eg. astroscrappy).
[0] https://wiki.debian.org/ReproducibleBuilds
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` [email protected] / chris-lamb.co.uk
`-
diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py
index 3772daf..ae40cd5 100644
--- a/Cython/Compiler/Nodes.py
+++ b/Cython/Compiler/Nodes.py
@@ -7817,7 +7817,8 @@ class ParallelStatNode(StatNode, ParallelNode):
def initialize_privates_to_nan(self, code, exclude=None):
first = True
- for entry, (op, lastprivate) in self.privates.items():
+ for entry, (op, lastprivate) in sorted(self.privates.items(),
+ key=lambda x: x[0].cname):
if not op and (not exclude or entry != exclude):
invalid_value = entry.type.invalid_value()
@@ -8079,7 +8080,8 @@ class ParallelStatNode(StatNode, ParallelNode):
c = self.begin_of_parallel_control_block_point
temp_count = 0
- for entry, (op, lastprivate) in self.privates.items():
+ for entry, (op, lastprivate) in sorted(self.privates.items(),
+ key=lambda x: x[0].cname):
if not lastprivate or entry.type.is_pyobject:
continue
@@ -8608,7 +8610,8 @@ class ParallelRangeNode(ParallelStatNode):
code.putln("#ifdef _OPENMP")
code.put("#pragma omp for")
- for entry, (op, lastprivate) in self.privates.items():
+ for entry, (op, lastprivate) in sorted(self.privates.items(),
+ key=lambda x: x[0].cname):
# Don't declare the index variable as a reduction
if op and op in "+*-&^|" and entry != self.target.entry:
if entry.type.is_pyobject: