3 ms·
This gets rid of temporary arrays, but this still isn't optimal if z is large. Memory locality means it's faster to apply a scalar operation like z2+c in a sing
by shoyer 6y ago
This gets rid of temporary arrays, but this still isn't optimal if z is large. Memory locality means it's faster to apply a scalar operation like z2+c in a single pass, rather than in two separate passes.
Explicitly unrolling loopy code (e.g., in pypy or Numba) is one easy way to achieve this, but you have to write more code.
Julia has some really nice syntax that lets you write things in this clean vectorized way but still get efficient code:
https://julialang.org/blog/2017/01/moredots/ https://julialang.org/blog/2017/01/moredots/
- joshuamorton 6y agoGotcha. I feel like I remember some numpy or scipy way of creating complex ufunc ops and applying them simultaneously, but maybe I'm misremembering or thinking np.vectorize was fast?