[Web-SIG] Request for Comments on upcoming WSGI Changes

René Dudfield renesd at gmail.com
Mon Sep 21 11:08:50 CEST 2009


On Mon, Sep 21, 2009 at 9:46 AM, Georg Brandl <g.brandl at gmx.net> wrote:
> René Dudfield schrieb:
>> On Mon, Sep 21, 2009 at 8:10 AM, Chris McDonough <chrism-ccARneWBNkgAvxtiuMwx3w at public.gmane.org> wrote:
>>>
>>> OTOH, I suspect the Python 3 stdlib is still broken if it requires native
>>> strings in various places (and prohibits the use of bytes).
>>
>> yes, python3 stdlib should support 'str'(the old unicode), 'buffer'
>> and 'bytes' for web using stuff.  Buffer is important because it's a
>> type also used for sockets(along with bytes) and it allows less memory
>> allocation (because you can reuse buffers).
>
> Please don't confuse readers and use the correct name, i.e. 'bytearray'
> instead of 'buffer'.
>
> Georg
>

Let me try and reduce the confusion...

There are two different python types the py3k socket module uses:
'bytes' and 'buffer'.  'bytes' is kind of like str in python3... but
with reduced functionality (no formatting, less methods etc).  buffer
is a Py_buffer from the c api.

buffer, and bytes in socket:
http://docs.python.org/3.1/library/socket.html#socket.socket.recvfrom_into
bytearray: http://docs.python.org/3.1/library/functions.html#bytearray
bytes: http://docs.python.org/3.1/library/functions.html#bytes
buffer: http://docs.python.org/3.1/c-api/buffer.html

This is separate, but related to the point of bytes vs unicode.  It is
really (bytes and buffer) vs unicode - since bytes and buffer can be
used with socket.  socket never uses a python2 'unicode', or a python3
'str' type.


More information about the Web-SIG mailing list