3 ms·
Even for floats & ints, try doing some array operations without allocating memory for intermediate results. In Julia, I can write whole PDE simulations that nev
by mfsch 6y ago
Even for floats & ints, try doing some array operations without allocating memory for intermediate results. In Julia, I can write whole PDE simulations that never allocate intermediate values inside the time integration loop. I haven’t done serious work with NumPy in a while, but I’m pretty sure that’s impossible for anything non-trivial, even a simple FD stencil such as `du[2:end-1] = D * (u[1:end-2] - 2*u[2:end-1] + u[3:end]) / dx^2`.
- eigenspace 6y agoAbsolutely. Numpy's performance model is so brittle that one needs to be very selective when they cherry-pick their microbenchmarks. My rule of thumb is that if your cherrypicked microbenchmark involves one specialized Numpy function call, it'll be fast, but if there is two separate specialized Numpy function calls it'll be slow.