Antoine Pitrou <solip...@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



_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to