Modern fortran is surpisingly pleasant to write. The last time optimisation came up, I tried the author's problem - multiplying two 4096x4096 matrices - in numpy, FORTRAN and Rust, on a standard laptop. Supposedly it took 9 hours in naive Python (I didn't try). Results were: Python3 (numpy 1.18.4) 1.3s FORTRAN (gfortran 9.3.0) 6.0s Rust (1.43.1, debug) >60s Rust (1.43.1, release) 4.0s What surprised me is that python…
So to be clear, numpy gives you a highly optimised matrix multiplication algorithm, and your FORTRAN solution was just something you threw together yourself, right? Little surprise that numpy roundly outperforms it, especially if it's using a different algorithm, such as Strassen rather than naive matrix multiplication. [0] > every single way I tried had "gotchas" and utterly astonishing behaviour in it As someone wh…
┌────────────────┬─────────────────┬──────┐
│ Language │ Detail │ Time │
├────────────────┼─────────────────┼──────┤
│ Python3 and C │ numpy 1.18.4 │ 1.3s │
│ FORTRAN │ gfortran 9.3.0 │ 6.0s │
│ Rust │ 1.43.1, debug │ >60s │
│ Rust │ 1.43.1, release │ 4.0s │
└────────────────┴─────────────────┴──────┘