[PATCH] D67817: [LNT] Python 3 support: adapt to map returning an iterator

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 01:01:42 PDT 2019


thopre marked 4 inline comments as done.
thopre added inline comments.


================
Comment at: lnt/external/stats/pstat.py:965
     if row1.dtype.char=='O' or row2.dtype=='O':
-        cmpvect = N.logical_not(abs(N.array(map(cmp,row1,row2)))) # cmp fcn gives -1,0,1
+        cmpvect = N.logical_not(abs(N.array(list(map(cmp, row1, row2))))) # cmp fcn gives -1,0,1
     else:
----------------
hubert.reinterpretcast wrote:
> Not the subject of this patch, but the `cmp` might be a problem.
Good catch again! I'll grep to see if there's more. I'll update the cmp patch accordingly.


================
Comment at: lnt/external/stats/stats.py:1569
     alldata = []
-    tmp = map(N.array,lists)
-    means = map(amean,tmp)
-    vars = map(avar,tmp)
-    ns = map(len,lists)
+    tmp = map(N.array, lists)
+    means = list(map(amean, tmp))
----------------
hubert.reinterpretcast wrote:
> thopre wrote:
> > hubert.reinterpretcast wrote:
> > > `tmp` is consumed twice immediately below, so the `list` application would still be appropriate if we aren't removing this block altogether.
> > Yes but map accepts an iterable so if the only uses are below (as the name tmp would imply) that change should be fine. I grepped LNT around for vars and means and couldn't find use elsewhere and git history isn't very informative. I've thus decided to remove the entire block.
> I agree with the removal of the block. On the now-moot point (in case it comes up in the future), by "consume" I did mean //destructively// consume. That is:
> ```
> tmp = map(str, [0, 1])
> a = list(tmp)
> b = list(tmp)  # Empty list!
> ```
Ah right silly me, of course. Thanks for pointing this out.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67817/new/

https://reviews.llvm.org/D67817





More information about the llvm-commits mailing list