[issue37596] Reproducible pyc: frozenset is not serialized in a deterministic order

Raymond Hettinger report at bugs.python.org
Mon Aug 23 20:19:22 EDT 2021


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Here's pure python code for experimentation:

    from marshal import dumps, loads

    def marshal_set(s):
        return dumps(sorted(s, key=dumps))

    def unmarshal_set(m):
        return frozenset(loads(m))

    def test(s):
        assert unmarshal_set(marshal_set(s)) == s
        
    test({("string", 1), ("string", 2), ("string", 3)})

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37596>
_______________________________________


More information about the Python-bugs-list mailing list