On 6 October 2014 07:24, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > anatoly techtonik wrote: >> >> That's a cool stuff. `bytes-like object` is really a much better name for >> users. > > > I'm not so sure. Usually when we talk about an "xxx-like object" we > mean one that supports a certain Python interface, e.g. a "file-like > object" is one that has read() and/or write() methods. But you can't > create an object that supports the buffer protocol by implementing > Python methods. > > I'm worried that using the term "bytes-like object" will lead > people to ask "What methods do I have to implement to make my > object bytes-like?", to which the answer is "mu".
That's a defect in the language definition, which requires volunteers willing and able to work through the task of defining and gathering consensus around a Python level counterpart to PEP 3118 that works across arbitrary Python implementations: http://bugs.python.org/issue13797 Ideally the drive for this would come from the Cython, PyPy, IronPython and Jython communities, as they would all likely benefit from a C independent way to express support for the buffer protocol. Enabling this level of flexibility in defining bytes-like objects is likely to be a key step in extending deep array oriented programming support from CPython to other Python implementations. In the meantime, the answer to "How do I define a bytes-like type?" is: 1. Use the appropriate implementation specific buffer protocols; or 2. Inherit from an existing bytes-like type Regards, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com