1. 22 Apr, 2019 1 commit
  2. 18 Apr, 2019 8 commits
  3. 16 Apr, 2019 7 commits
  4. 15 Apr, 2019 4 commits
    • Niels Thykier's avatar
      cruft-report: Refactor to improve looping over dicts · 9a4d7e56
      Niels Thykier authored
      This commit aims to pre-empty some of the 2to3 delta while also
      using more concise constructs.
      
      Examples include:
      
         y = x.keys()
         y.sort(...)
      
      is rewritten into:
      
         y = sorted(x.keys(), ...)
      
      (Except in one case, where we really wanted "max" rather than "sort".)
      Signed-off-by: Niels Thykier's avatarNiels Thykier <niels@thykier.net>
      9a4d7e56
    • Niels Thykier's avatar
      Replace most calls to "map" with comprehensions · 6e24f59a
      Niels Thykier authored
      They are compatible with python2 + python3 and the 2to3 rewrite will
      do a similar transformation.  However, with this rewrite, we can
      improve the generated results a bit to avoid some suboptimal cases
      while also reducing the delta for the py2 and py3 variants of dak.
      
      As an example:
          filelist = []
          for ... in ...:
              filelist += map(lambda x: os.path.join(r, x),
                               filter(lambda x: x.endswith('.changes'), f))
      
      Here 2to3 offers the following rewrite:
      
          filelist = []
          for ... in ...:
              filelist += [os.path.join(r, x) for x in [x for x in f if x.endswith('.changes')]]
      
      But this is performance-wise much better written as:
      
           filelist = []
           for ... in ...:
               filelist.extend(os.path.join(r, x) for x in f if x.endswith('.changes'))
      
      The original code and the 2to3 variant produces a lot of temporary
      lists only to discard them again (in python2 filter + map generates a
      list each).  In the optimized variant, we avoid all the temporary
      lists by using a generator-comprehension.
      Signed-off-by: Niels Thykier's avatarNiels Thykier <niels@thykier.net>
      6e24f59a
    • Niels Thykier's avatar
      Rewrite some uses of keys() in if-statements · fb37242e
      Niels Thykier authored
      This rewrites the following statements:
      
          if a in b.keys():
      
      to
      
          if a in b:
      
      At the moment, both variants are cheap (i.e. O(1)) operations.
      However, the 2to3 will blindly rewrite the former into a more
      expensive variant, namely:
      
          if a in list(b.keys()):
      
      Sadly, this becomes O(|b|) as __contains__ on a list is a lot more
      expensive than it is on a directory/set-like structure.
      Signed-off-by: Niels Thykier's avatarNiels Thykier <niels@thykier.net>
      fb37242e
    • Niels Thykier's avatar
      tests: Fix a deprecation warning from the tests in python3 · 23eda7ff
      Niels Thykier authored
      This change is compatible with python2 and removes some 50-100 lines
      of "deprecation warning"-noise when trying to test dak with python3.
      Signed-off-by: Niels Thykier's avatarNiels Thykier <niels@thykier.net>
      23eda7ff
  5. 14 Apr, 2019 14 commits
  6. 13 Apr, 2019 6 commits