comparison tests/test-revlog-raw.py @ 44452:9d2b2df2c2ba

cleanup: run pyupgrade on our source tree to clean up varying things Built with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**' | xargs pyupgrade --keep-percent-format --keep-extraneous-parens and then blackened. pyupgrade comes from https://github.com/asottile/pyupgrade with a patch to let me preserve extraneous parens (which we use for marking strings that shouldn't be translated), and lets us clean up a bunch of idioms that have cruftily accumulated over the years. # skip-blame no-op automated code cleanups Differential Revision: https://phab.mercurial-scm.org/D8255
author Augie Fackler <augie@google.com>
date Fri, 06 Mar 2020 13:27:41 -0500
parents 2372284d9457
children 89a2afe31e82
comparison
equal deleted inserted replaced
44449:ff72bd52d56a 44452:9d2b2df2c2ba
227 ''' 227 '''
228 m = 2 ** n 228 m = 2 ** n
229 229
230 # Gray Code. See https://en.wikipedia.org/wiki/Gray_code 230 # Gray Code. See https://en.wikipedia.org/wiki/Gray_code
231 gray = lambda x: x ^ (x >> 1) 231 gray = lambda x: x ^ (x >> 1)
232 reversegray = dict((gray(i), i) for i in range(m)) 232 reversegray = {gray(i): i for i in range(m)}
233 233
234 # Generate (n * 2) bit gray code, yield lower n bits as X, and look for 234 # Generate (n * 2) bit gray code, yield lower n bits as X, and look for
235 # the next unused gray code where higher n bits equal to X. 235 # the next unused gray code where higher n bits equal to X.
236 236
237 # For gray codes whose higher bits are X, a[X] of them have been used. 237 # For gray codes whose higher bits are X, a[X] of them have been used.