Skip to content

Commit

Permalink
feat: speed up constructing Variant objects (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 25, 2023
1 parent eeabcd5 commit 0d7a665
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/dbus_fast/signature.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ cdef class SignatureTree:

cdef class Variant:

cdef public object type
cdef public object signature
cdef public SignatureType type
cdef public str signature
cdef public object value

@cython.locals(signature_tree=SignatureTree)
cdef _init_variant(self, object signature, object value, bint verify)
8 changes: 8 additions & 0 deletions src/dbus_fast/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,14 @@ def __init__(
verify: bool = True,
) -> None:
"""Init a new Variant."""
self._init_variant(signature, value, verify)

def _init_variant(
self,
signature: Union[str, SignatureTree, SignatureType],
value: Any,
verify: bool,
) -> None:
if type(signature) is SignatureTree:
signature_tree = signature
self.signature = signature_tree.signature
Expand Down

0 comments on commit 0d7a665

Please sign in to comment.