Skip to content

Commit

Permalink
feat: speed up marshall write_string and write_variant (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 3, 2022
1 parent 3b2efff commit 71cf524
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/dbus_fast/_private/marshaller.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cdef class Marshaller:
signature_len=cython.uint,
written=cython.uint,
)
cpdef write_string(self, object value, object _type)
cpdef write_string(self, str value, object _type)

@cython.locals(
signature_len=cython.uint,
Expand Down Expand Up @@ -59,6 +59,8 @@ cdef class Marshaller:

@cython.locals(
written=cython.uint,
signature=cython.str,
signature_bytes=cython.bytes,
)
cpdef write_variant(self, object variant, object type)

Expand Down
4 changes: 3 additions & 1 deletion src/dbus_fast/_private/marshaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def write_string(self, value, type_: SignatureType) -> int:
return written

def write_variant(self, variant: Variant, type_: SignatureType) -> int:
written = self._write_signature(variant.signature.encode())
signature = variant.signature
signature_bytes = signature.encode()
written = self._write_signature(signature_bytes)
written += self._write_single(variant.type, variant.value)
return written

Expand Down

0 comments on commit 71cf524

Please sign in to comment.