discuss.python.org
Add zero-copy conversion of `bytearray` to `bytes` by providing `__bytes__()`
Currently to be efficient in Python, a “zero copy” / “zero extra memory” pure-python I/O loop needs to: Use a mutable buffer of bytes (bytearray) buf = bytearray(BUFFER_SIZE) Fill it using file.read...