]> sigrok.org Git - libsigrokdecode.git/commitdiff
common: rephrase bitpack(), use list comprehension Python idiom
authorGerhard Sittig <redacted>
Sun, 1 Jul 2018 13:26:09 +0000 (15:26 +0200)
committerUwe Hermann <redacted>
Sun, 15 Jul 2018 18:16:39 +0000 (20:16 +0200)
decoders/common/srdhelper/mod.py

index 3c495b430458d0078c35662b2a4197ff62c3ec76..e37345a0b34f1a416c5c6b407cc746ad9b80ae4c 100644 (file)
@@ -25,10 +25,7 @@ def bin2int(s: str):
     return int('0b' + s, 2)
 
 def bitpack(bits):
-    res = 0
-    for i, b in enumerate(bits):
-        res |= b << i
-    return res
+    return sum([b << i for i, b in enumerate(bits)])
 
 def bitunpack(num, minbits=0):
     res = []