[pygobject/bochecha/gvariant-unpack] variant: Create a tuple directly



commit 527bcf74aa2f2cfbf13f2e3af46ffb3819f08141
Author: Mathieu Bridon <mathieu hashbang fr>
Date:   Tue Jul 23 16:58:27 2019 +0200

    variant: Create a tuple directly
    
    This avoids iterating twice: once to create the list with a
    list-comprehension and a second time to transform that list into a
    tuple.

 gi/overrides/GLib.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 83cbb7fb..78d309b6 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -246,9 +246,8 @@ class Variant(GLib.Variant):
 
         # tuple
         if type_string.startswith('('):
-            res = [self.get_child_value(i).unpack()
-                   for i in range(self.n_children())]
-            return tuple(res)
+            return tuple(self.get_child_value(i).unpack()
+                         for i in range(self.n_children()))
 
         # dictionary
         if type_string.startswith('a{'):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]