Skip to content

bpo-34141: Optimized pickling simple non-recursive values. #8318

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 17, 2018

@@ -3952,7 +3949,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
1 if a persistent id was saved.
*/
if ((status = save_pers(self, obj)) != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this trigger a recursive call?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save_pers() calls save() with pers_save=1, and this stops the recursion via save_pers.

@pitrou
Copy link
Member

pitrou commented Jul 17, 2018

On the principle I like this.

@serhiy-storchaka
Copy link
Member Author

Thank you. Do you have to suggest any explanation comments?

}
else if (type == &PyDict_Type) {

if (Py_EnterRecursiveCall(" while pickling an object")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a comment such as """We're only calling Py_EnterRecursiveCall here so that atomic types above are pickled faster"""?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@serhiy-storchaka serhiy-storchaka merged commit 5d4cb54 into python:master Jul 18, 2018
@serhiy-storchaka serhiy-storchaka deleted the pickle-non-recursive-optimize branch July 18, 2018 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants