From ef7acdcbe59123bfa3b17d5dafc9f8235ac0f360 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 4 Nov 2022 11:41:59 +0100 Subject: [PATCH] feat: small speed up to _unpack_variants (#148) --- src/dbus_fast/unpack.pxd | 5 ++++- src/dbus_fast/unpack.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dbus_fast/unpack.pxd b/src/dbus_fast/unpack.pxd index 5fa9e8dc..55ebef1b 100644 --- a/src/dbus_fast/unpack.pxd +++ b/src/dbus_fast/unpack.pxd @@ -2,9 +2,12 @@ import cython +from .signature cimport Variant -cdef object Variant cpdef unpack_variants(object data) +@cython.locals( + var=Variant +) cdef _unpack_variants(object data) diff --git a/src/dbus_fast/unpack.py b/src/dbus_fast/unpack.py index 135a747d..9680ff34 100644 --- a/src/dbus_fast/unpack.py +++ b/src/dbus_fast/unpack.py @@ -19,5 +19,6 @@ def _unpack_variants(data: Any) -> Any: if type(data) is list: return [_unpack_variants(item) for item in data] if type(data) is Variant: - return _unpack_variants(data.value) + var = data + return _unpack_variants(var.value) return data