Message168372
Martin v. Loewis <report@bugs.python.org> wrote:
> I would be fine with deprecating the 'u' type arrays, acknowledging
> that the Py_UNICODE element type is even more useless now than before.
> If that is done, there is no point in fixing anything about it. If
> it exports using the 'u' and 'w' codes - fine. If then memoryview
> doesn't work properly - fine; this is a deprecated feature.
From the perspective of memoryview backwards compatibility, deprecation is fine.
In 3.2, memoryview could really only handle one-dimensional buffers of unsigned
bytes:
>>> import array
>>> a = array.array('u', "ABC")
>>> x = memoryview(a)
>>> a[0] == x[0]
False
>>> a[0]
'A'
# Indexing returns bytes instead of str:
>>> x[0]
b'A\x00'
>>>
# Index assignment attempts to do slice assignment:
>>> x[0] = 'Z'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface
>>>
I'm +1 for deprecating 'u' and 'w' in the array module, accept that memoryview
cannot handle 'u' and 'w' and fix the situation properly in 3.4. I agree that
the latter would require people to come up with actual use cases. |
|
Date |
User |
Action |
Args |
2012-08-16 11:34:17 | skrah | set | recipients:
+ skrah, loewis, teoliphant, ncoghlan |
2012-08-16 11:34:17 | skrah | link | issue15625 messages |
2012-08-16 11:34:16 | skrah | create | |
|