News for hackers. Stuff that matters.
Re:Pythran: Crossing the Python Frontier [pdf] by eljost on Tuesday April 24, 2018 @04:58AM (#16911017)
Interesting article but just skimming through it some things stand out immediately: 1.) The first snippet isn't even valid python code as floats don't have a shape attribute.

  s = 0. 
  n = s.shape
2.) The inline latex math isn't rendered properly.
Re:Pythran: Crossing the Python Frontier [pdf] by kristofferc on Tuesday April 24, 2018 @06:37AM (#16911382)
The first snippet also doesn't balance the parenthesis

    s += 100. * x[i + 1] - x[i] ** 2.) ** 2. + (1 - x[i]) ** 2
Re:Pythran: Crossing the Python Frontier [pdf] by chestervonwinch on Tuesday April 24, 2018 @06:57AM (#16911468)
It should be the shape of x (actually, the zero'th element of the shape), but this is also a tad odd because this would assume that x is a numpy array, which isn't introduced until after this 'naive pure python' code block (i.e., before numpy is even introduced in the text).
Re:Pythran: Crossing the Python Frontier [pdf] by rlayton2 on Tuesday April 24, 2018 @06:42AM (#16911397)
I believe the input should be a numpy array of floats which has a shape attribute
Re:Pythran: Crossing the Python Frontier [pdf] by serge-ss-paille on Tuesday April 24, 2018 @08:32AM (#16911961)
(shameful author here)

One should read

  def rosen_explicit_loop(x): 
    s = 0. 
    n = x.shape[0] 
    for i in range(0, n - 1): 
      s += 100. * (x[i + 1] - x[i] ** 2.) ** 2. + (1 - x[i]) ** 2 
    return s
(edited)
Re:Pythran: Crossing the Python Frontier [pdf] by chestervonwinch on Tuesday April 24, 2018 @09:00AM (#16912150)
...

    n = x.shape[0]
Re:Pythran: Crossing the Python Frontier [pdf] by quietbritishjim on Tuesday April 24, 2018 @12:22PM (#16913987)
Or just len(x). This works perfectly well on numpy arrays and has the bonus that it works on regular lists/tuples of floats, so the first snippet doesn't rely on numpy.