Skip to content

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

Merged
serhiy-storchaka merged 2 commits into
python:masterfrom
serhiy-storchaka:pickle-non-recursive-optimize
Jul 18, 2018
Merged

bpo-34141: Optimized pickling simple non-recursive values.#8318
serhiy-storchaka merged 2 commits into
python:masterfrom
serhiy-storchaka:pickle-non-recursive-optimize

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

Comment thread Modules/_pickle.c
@@ -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
Copy Markdown
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
Copy Markdown
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

pitrou commented Jul 17, 2018

Copy link
Copy Markdown
Member

On the principle I like this.

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

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

Comment thread Modules/_pickle.c
}
else if (type == &PyDict_Type) {

if (Py_EnterRecursiveCall(" while pickling an object")) {

Copy link
Copy Markdown
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
Copy Markdown
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