Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

See issue27572 for moving in opposite direction. Supporting the buffer protocol 
rather of just bytes and bytearray complicates the code, and can be considered 
as a feature creep, especially if an input is a text encoded as bytes.

But in this case the bytes argument of IPv4Address() is not a text 
representation like b'127.0.0.1', but a packed array of bytes like bytes([127, 
0, 0, 1]). Accepting bytearray and memoryview makes more sense for it. Yet I'm 
not sure that supporting them is worth adding an overhead. This will affect 
every call of the IPv4Address constructor, and I think that this is not the 
most common case.

Maybe add a special purposed named constructor IPv4Address.from_bytes() that 
will accept any objects supporting the buffer protocol?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34465>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to