From 89026e3b597bd1a318114b6cf50e27d29d9cbca8 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 1 Feb 2025 23:37:13 -0600 Subject: [PATCH] feat: speed up bytearray creation in unmarshaller (#382) --- src/dbus_fast/_private/unmarshaller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dbus_fast/_private/unmarshaller.py b/src/dbus_fast/_private/unmarshaller.py index 07fde8f..85ca17f 100644 --- a/src/dbus_fast/_private/unmarshaller.py +++ b/src/dbus_fast/_private/unmarshaller.py @@ -243,7 +243,7 @@ class Unmarshaller: 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 @@ -280,7 +280,7 @@ class Unmarshaller: 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