On 10 February 2016 at 06:54, Guido van Rossum guido@python.org wrote:
[Just adding to Andrew's response]
On Tue, Feb 9, 2016 at 9:58 AM, Andrew Barnert via Python-Dev python-dev@python.org wrote:
On Feb 9, 2016, at 03:44, Phil Thompson phil@riverbankcomputing.com wrote:
There are a number of things I'd like to express but cannot find a way to do so...
- objects that implement the buffer protocol
That seems like it should be filed as a bug with the typing repo. Presumably this is just an empty type that registers bytes, bytearray, and memoryview, and third-party classes have to register with it manually?
Hm, there's no way to talk about these in regular Python code either, is there? I think that issue should be resolved first. Probably by adding something to collections.abc. And then we can add the corresponding name to typing.py. This will take time though (have to wait for 3.6) so I'd recommend 'Any' for now (and filing those bugs).
Somewhat related, there's actually no way to export PEP 3118 buffers directly from a type implemented in Python: http://bugs.python.org/issue13797
Cython and PyPy each have their own approach to handling that, but there's no language level cross-interpreter convention
A type (e.g. BytesLike, given the change we made to relevant error messages) could still be added to collections.abc without addressing that problem, it would just need to be empty and used only for explicit registration without any structural typing support.
Regards, Nick.