-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-78274: Produce consistent output from marshal.dumps(). #28379
gh-78274: Produce consistent output from marshal.dumps(). #28379
Conversation
@gvanrossum, is something like this what you had in mind? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, but I'm probably not going to be able to review it before Monday.
126d491
to
8f9ba8d
Compare
@@ -1789,6 +1837,8 @@ marshal.dumps | |||
version: int(c_default="Py_MARSHAL_VERSION") = version | |||
Indicates the data format that dumps should use. | |||
/ | |||
* | |||
stable: bool = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably make sense to default to False
for now, so users would effectively opt-in to the performance penalty. (The same goes for marshal.dump()
.)
As I noted in [bpo-34093](https://bugs.python.org/issue34093#msg402244), we could take a different approach to get the same stable output without having to call |
This PR should probably also add a flag to determine if the import machinery would use |
This PR is stale because it has been open for 30 days with no activity. |
Maybe just close this? We no longer require marshal output to be stable for
the freezing project, because we don't commit the files to git any more.
|
We need to this to support "reproducible build" in downstream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has merge conflicts now.
When you're done making the requested changes, leave the comment: |
Closing; see discussion in the issue. |
The result on debug vs. non-debug builds were slightly different. This PR fixes that by making an additional pass over the object to ensure "refs" are used more than once. Consequently,
marshal.dumps()
is substantially slower. To mitigate this, I've added to it a keyword-only arg, "stable", to allow folks to opt out.FYI, I discovered gh-8293 after the fact, which turns out to have a lot of similarities to this PR.