[Python-Dev] PEP 467: last round (?) (original) (raw)

Koos Zevenhoven k7hoven at gmail.com
Sat Sep 3 18:21:32 EDT 2016


On Sat, Sep 3, 2016 at 6:41 PM, Ethan Furman <ethan at stoneleaf.us> wrote:

Open Questions ============== Do we add iterbytes to memoryview, or modify memoryview.cast() to accept 's' as a single-byte interpretation? Or do we ignore memory for now and add it later? Apparently memoryview.cast('s') comes from Nick Coghlan: <https://marc.info/?i=CADiSq7e=8ieyeW-tXf5diMS5NuAOS5udv-3gw3LTWN9WboJw@mail.gmail.com>. However, since 3.5 (https://bugs.python.org/issue15944) you can call cast("c") on most memoryviews, which I think already does what you want:

tuple(memoryview(b"ABC").cast("c")) (b'A', b'B', b'C') Nice!

Indeed! Exposing this as bytes_instance.chars would make porting from Python 2 really simple. Of course even better would be if slicing the view would return bytes, so the porting rule would be the same for all bytes subscripting:

py2str[SOMETHING]

becomes

py3bytes.chars[SOMETHING]

With the "c" memoryview there will be a distinction between slicing and indexing.

And Random832 seems to be making some good points.

--- Koos

-- Ethan


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/k7hoven%40gmail.com

--



More information about the Python-Dev mailing list