Skip to content

Commit

Permalink
feat: speed up bytearray creation in unmarshaller (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Feb 2, 2025
1 parent f6f2497 commit 89026e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dbus_fast/_private/unmarshaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def __init__(
negotiate_unix_fd: bool = True,
) -> None:
self._unix_fds: list[int] = []
self._buf = bytearray() # Actual buffer
self._buf = bytearray.__new__(bytearray) # Actual buffer
self._stream = stream
self._sock = sock
self._message: Optional[Message] = None
Expand Down Expand Up @@ -280,7 +280,7 @@ def _next_message(self) -> None:
self._unix_fds = []
to_clear = HEADER_SIGNATURE_SIZE + self._msg_len
if len(self._buf) == to_clear:
self._buf = bytearray()
self._buf = bytearray.__new__(bytearray)
else:
del self._buf[:to_clear]
self._msg_len = 0 # used to check if we have ready the header
Expand Down

0 comments on commit 89026e3

Please sign in to comment.