[Python-Dev] Misc re.match() complaint
Serhiy Storchaka
storchaka at gmail.com
Wed Jul 17 15:12:34 CEST 2013
16.07.13 20:21, Guido van Rossum написав(ла):
> The situation is most egregious if the target string is a bytearray,
> where there is currently no way to get the result as an immutable
> bytes object without an extra copy. (There's no API that lets you
> create a bytes object directly from a slice of a bytearray.)
m = memoryview(data)
if m:
return m.cast('B')[low:high].tobytes()
else:
# cast() doesn't work for empty memoryview
return b''
More information about the Python-Dev
mailing list