Antoine Pitrou <solipsis at pitrou.net> wrote: > > I would like to fix this in the features/pep-3118 repository as follows: > > > > - memoryview should respect the format specifiers. > > > > - bytearray and friends should set the format specifier to "c" > > in their getbuffer() methods. > > > > - Introduce a new function PyMemoryView_FromBytes() that can be used > > instead of PyMemoryView_FromBuffer(). PyMemoryView_FromBuffer() > > is usually used in conjunction with PyBuffer_FillInfo(), which > > sets the format specifier to "B". > > What would PyMemoryView_FromBytes() do? The name suggests it takes a > bytes object, but you can already use PyMemoryView_FromObject() for > that. Oh no, the name isn't quite right then. It should be a replacement for the combination PyBuffer_FillInfo()/PyMemoryView_FromBuffer() and it should temporarily wrap a C-string. Also, unlike that combination, it would set the format specifier to "c". Perhaps this name is better: PyObject * PyMemoryView_FromCString(char *s, Py_ssize_t size, int flags); 'flags' is just PyBUF_READ or PyBUF_WRITE. In the Python source tree, it could completely replace PyBuffer_FillInfo() and PyMemoryView_FromBuffer(). Stefan Krah
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4