Re: [Python-Dev] Adding bytes.frombuffer() constructor to PEP 467

2017年1月05日 16:15:07 -0800

>
> bytes.frombuffer(x) is bytes(memoryview(x)) or memoryview(x).tobytes().
>
There is pitfall: memoryview should be closed.
So b = bytes.frombuffer(x) is:
with memoryview(x) as m:
 b = bytes(m)
 # or b = m.tobytes()
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to