Guido van Rossum wrote:
Hm, yes this seems reasonable. Travis, what do you think of this?

On Sat, Apr 26, 2008 at 1:51 PM, Alexandre Vassalotti
<[EMAIL PROTECTED]> wrote:
 Would it be a good idea to make memoryview indexing consistent with
 the behaviour of bytes object?

  >>> memoryview(b'hello')[0]
  bytearray(b'h')
  >>> b'hello'[0]
  104

I'm not sure that we should rush into this. There are reasons for the differences.

The idea is that an "element" of a memory-view object be a bytes object (either a bytearray or a bytes object depending on mutability of the original memoryview object --- seems like it should be a bytes object in this case).

Remember that an "element" of a memory-view object can have more than one byte depending on the format attribute. So, I'm not sure what is gained by special-casing the 1-byte item except possible confusion later.

Perhaps it is useful to special-case this one, but then you lose useful mutability. My feel right now is to not do the special case at all and actually return a memory-view object even for element access (this is especially needed, I think for nested formats which arise in memory-mapping files which provides some very handy io-related functionality). Then, we should leave it to method call to extract a bytes object as desired.

-Travis



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

Reply via email to