From 74595b24e187d0c643c63639588eaba8578069eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= <inform@tiker.net>
Date: Wed, 10 Mar 2021 15:41:10 -0600
Subject: [PATCH] unordered_hash: Explain why sys-independent despite use of
 sys.byteorder

---
 pytools/__init__.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/pytools/__init__.py b/pytools/__init__.py
index 6330869..ae06dd1 100644
--- a/pytools/__init__.py
+++ b/pytools/__init__.py
@@ -2632,6 +2632,11 @@ def unordered_hash(hash_constructor, iterable):
     for i in iterable:
         h_i = hash_constructor()
         h_i.update(i)
+        # Using sys.byteorder (for efficiency) here technically makes the
+        # hash system-dependent (which it should not be), however the
+        # effect of this is undone by the to_bytes conversion below, while
+        # left invariant by the intervening XOR operations (which do not
+        # mix adjacent bits).
         h_int = h_int ^ int.from_bytes(h_i.digest(), sys.byteorder)
 
     h = hash_constructor()
-- 
GitLab