feat: speed up marshalling messages (#383)

This commit is contained in:
J. Nick Koston 2025-02-02 16:51:29 -06:00 committed by GitHub
parent fdb8212122
commit d7213be285
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 = {