Displaying 1 result from an estimated 1 matches for "astyp".
Did you mean:
astpp
2012 Jan 28
2
Need very fast application of 'diff' - ideas?
...ld kill any improvements. I don't have much experience integrating other languages, so I'm hoping the community has some ideas about how to approach this particular problem...
Many thanks,
Kevin
In iPython:
In [3]: import numpy as np
In [4]: arr = np.random.randint(0, 1000, (10000000,1)).astype("int16")
In [5]: arr1 = arr[1:].view()
In [6]: timeit arr2 = arr1 - arr[:-1]
10 loops, best of 3: 20.1 ms per loop
In Clojure:
(defn subtract-lag
[n]
(let [v (take n (repeatedly rand))]
(time (dorun (map - v (cons 0 v))))))
[[alternative HTML version deleted]]