[issue29729] RFE: uuid.UUID(bytes=...): support bytes-like types, not only bytes

STINNER Victor report at bugs.python.org
Thu Sep 28 16:21:18 EDT 2017


STINNER Victor <victor.stinner at gmail.com> added the comment:

> The code doesn't work nice with general objects supporting the buffer protocol. The length check suppose that the value has a length, and it is the size in bytes. The code for bytes_le suppose that the value supports slicing and concatenating results of the slicing. And all this code is made as fast as possible. Additional checks and conversions will slowdown it.

I enhanced my PR to also accept memoryview and bytearray in bytes_le. I don't think that performance matters so much here. First we need correctness, accept any bytes-like objects, no?

----------

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


More information about the Python-bugs-list mailing list