From d7213be28578b3effa3aeea85bab5de92bba224d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 2 Feb 2025 16:51:29 -0600 Subject: [PATCH] feat: speed up marshalling messages (#383) --- src/dbus_fast/constants.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/dbus_fast/constants.py b/src/dbus_fast/constants.py index fe70b6e..1beb9f6 100644 --- a/src/dbus_fast/constants.py +++ b/src/dbus_fast/constants.py @@ -1,4 +1,5 @@ from enum import Enum, IntFlag +from functools import cached_property class BusType(Enum): @@ -18,6 +19,11 @@ class MessageType(Enum): ERROR = 3 #: A return to a method call that has failed SIGNAL = 4 #: A broadcast signal to subscribed connections + @cached_property + def value(self) -> str: + """Return the value.""" + return self._value_ + MESSAGE_TYPE_MAP = {field.value: field for field in MessageType} @@ -30,6 +36,11 @@ class MessageFlag(IntFlag): NO_AUTOSTART = 2 ALLOW_INTERACTIVE_AUTHORIZATION = 4 + @cached_property + def value(self) -> str: + """Return the value.""" + return self._value_ + # This is written out because of https://github.com/python/cpython/issues/98976 MESSAGE_FLAG_MAP = {