Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing the file reader buffer from `bytes` to `bytearray` significantly reduces CPU usage. Using `bytes` is inefficient because it's immutable: you get the classic string building problem, where repeatedly appending to an immutable sequence requires O(n^2) operations. From [the python docs](https://docs.python.org/3/library/stdtypes.html#common-sequence-operations): > if concatenating bytes objects, you can similarly use bytes.join() or io.BytesIO, or you can do in-place concatenation with a bytearray object. bytearray objects are mutable and have an efficient overallocation mechanism I tried `io.BytesIO` too, but `bytearray` has slightly better performance in my testing.
- Loading branch information