Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements #19 (comment)
For now, this is what I have chosen for the behavior of "deterministic" mode:
set
andfrozenset
will be sorted before being pickled.set
andfrozenset
will not be effected (and will remain nondeterministic) because they can implement their own__reduce__
functions which don't have to follow the conventions ofset
's pickling procedure.complex
), they will be sorted by their hash instead. This will not create a natural order of elements that is easy to understand, but if the__hash__
function of the class doesn't depend onid
, it will be deterministic.dict
and subclasses will remain pickled in insertion order.code
objects will not have their line numbers removed and the file name and function name will not be modified.save_code
like they already do, but issues like incorrect traceback from serialized function in python 3.10 #488 would make that difficult to maintain and it would be best to try to find a way to emit information that would help users selectively zero out/ignore line information in code objects when hashing. That way, information that debuggers need still remains in the pickle, but the hash remains consistent.