[issue17711] Persistent id in pickle with protocol version 0

Serhiy Storchaka report at bugs.python.org
Sun Apr 14 10:33:29 CEST 2013


Serhiy Storchaka added the comment:

I think a string with character codes < 256 will be better for test_protocol0_is_ascii_only(). It can be latin1 encoded (Python 2 allows any 8-bit strings).

PyUnicode_AsASCIIString() can be slower than _PyUnicode_AsStringAndSize() (actually PyUnicode_AsUTF8AndSize()) because the latter can use cached value. You can check if the persistent id only contains ASCII characters by checking PyUnicode_GET_LENGTH(pid_str) == size.

And what are you going to do with the fact that in Python 2 you can pickle non-ascii persistent ids, which will not be able to unpickle in Python 3?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17711>
_______________________________________


More information about the Python-bugs-list mailing list