From: Uwe Hermann Date: Sun, 18 Apr 2010 00:02:35 +0000 (+0200) Subject: Python: Use range instead of xrange. X-Git-Tag: libsigrokdecode-0.1.0~338 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a5fdab452f682e50cc05d6f392f750473fd93e78;p=libsigrokdecode.git Python: Use range instead of xrange. For small numbers range seems to be faster, and xramge is being removed anyway in Python 3 AFAIK. --- diff --git a/scripts/transitioncounter.py b/scripts/transitioncounter.py index 05a07e3..7c9c6a3 100644 --- a/scripts/transitioncounter.py +++ b/scripts/transitioncounter.py @@ -40,7 +40,7 @@ def sigrokdecode_count_transitions(inbuf): # Presets... oldbyte = inbuf[0] - for i in xrange(channels): + for i in range(channels): oldbit[i] = (oldbyte & (1 << i)) != 0 # Loop over all samples. @@ -49,7 +49,7 @@ def sigrokdecode_count_transitions(inbuf): # Optimization: Skip identical bytes (no transitions). if oldbyte == s: continue - for i in xrange(channels): + for i in range(channels): curbit = (s & (1 << i) != 0) # Optimization: Skip identical bits (no transitions). if oldbit[i] == curbit: @@ -61,17 +61,17 @@ def sigrokdecode_count_transitions(inbuf): oldbit[i] = curbit # Total number of transitions is the sum of rising and falling edges. - for i in xrange(channels): + for i in range(channels): transitions[i] = rising[i] + falling[i] outbuf += "Rising edges: " - for i in xrange(channels): + for i in range(channels): outbuf += str(rising[i]) + " " outbuf += "\nFalling edges: " - for i in xrange(channels): + for i in range(channels): outbuf += str(falling[i]) + " " outbuf += "\nTransitions: " - for i in xrange(channels): + for i in range(channels): outbuf += str(transitions[i]) + " " outbuf += "\n"