1 """Implementation of a ring buffer using bytearray."""
5 """Basic ring buffer using a bytearray.
11 """Initialize empty buffer."""
19 """Return the maximum size of the buffer."""
24 """Return the current put position."""
28 """Return the length of data stored in the buffer."""
31 def put(self, data: bytes) ->
None:
32 """Put a chunk of data into the buffer, possibly wrapping around."""
34 new_pos = self.
_pos_pos + data_len
35 if new_pos >= self.
_maxlen_maxlen:
38 num_bytes_2 = new_pos - self.
_maxlen_maxlen
41 self.
_buffer_buffer[:num_bytes_2] = data[num_bytes_1:]
42 new_pos = new_pos - self.
_maxlen_maxlen
47 self.
_pos_pos = new_pos
51 """Get bytes written to the buffer."""
None __init__(self, int maxlen)
None put(self, bytes data)