News for hackers. Stuff that matters.
Re:A supercomputer often won’t make your code run faster by njam on Thursday December 14, 2017 @09:50AM (#15922626)
You're spot on with vectorisation. It needs to be emphasized in academia. Take numpy/pandas, even for basic stuff the efficiency difference vs a for loop is vast:

  def product_sum(a, b):
      total = 0
      for a, b in zip(a, b):
          total += a * b
      return total
  %timeit product_sum(million_a, million_b)
  215 ms ± 3.01 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
  %timeit (million_a * million_b).sum()
  6.01 ms ± 254 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

There are no comments on this comment yet.