[issue31993] pickle.dump allocates unnecessary temporary bytes / str

Olivier Grisel report at bugs.python.org
Sat Nov 11 10:39:07 EST 2017


Olivier Grisel <olivier.grisel at ensta.org> added the comment:

Alright, I found the source of my refcounting bug. I updated the PR to include the C version of the dump for PyBytes.

I ran Serhiy's microbenchmarks on the C version and I could not detect any overhead on small bytes objects while I get a ~20x speedup (and no-memory copy) on large bytes objects as expected.

I would like to update the `write_utf8` function but I would need to find a way to wrap `const char* data` as a PyBytes instance without making a memory copy to be able to pass it to my `_Pickle_write_large_bytes`. I browsed the C-API documentation but I could not understand how to do that.

Also I would appreciate any feedback on the code style or things that could be improved in my PR.

----------

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


More information about the Python-bugs-list mailing list