Add `take_bytes([n])` to `bytearray` providing a zero-copy path to `bytes`

bytearray supports fast deletion at the start and at the end, it avoids resizing the buffer in most cases. Using bytes or PyBytesWriter inside bytearray may lose this optimization, no?

1 Like