[Python-ideas] collections.abc.BytesLike or ...? [was: [Python-Dev] bytes-like objects]

Jan Kaliszewski zuo at kaliszewski.net
Mon Oct 6 00:42:07 CEST 2014


2014-10-05 Victor Stinner <victor.stinner at gmail.com> dixit:

> I prefer "bytes-like" than "buffer protocol". By the way, is there a
> documentation in Python doc which explains "bytes-like" and maybe
> list most compatible types?
> 
> I'm not sure that the term has an unique definition. In some parts of
> Python, I saw explicit checks on the type: bytes or bytearray,
> sometimes memoryview is accepted. The behaviour is different in C
> functions using PyArg API. It probably depends if the function relies
> on the content (read bytes) or on methods (ex: call .find).

Maybe an ABC would be useful for isinstance checks?

Or some kind of almost-an-ABC-which-does-not-allow-to-register-
-arbitrary-virtual-subclasses?

Cheers.
*j


More information about the Python-ideas mailing list