News for hackers. Stuff that matters.
Re:Faster CPython at PyCon, part one by vbarrielle on Thursday May 11, 2023 @04:53PM (#35908233)
Due to the possibility to fuse multiple operations in C++ (whereas you often have intermediate arrays in numpy), I routinely get 20x speedups when porting from numpy to C++. Good libraries like eigen help a lot.
Re:Faster CPython at PyCon, part one by arjvik on Thursday May 11, 2023 @05:39PM (#35908744)
What's an example of fusing operations?

Are you talking about combinations of operations that are used commonly enough to warrant Eigen methods that perform them at once in SIMD?

Re:Faster CPython at PyCon, part one by celrod on Thursday May 11, 2023 @05:55PM (#35908921)
Probably that eigen uses expression templates to avoid the needles creation of temporaries.
Re:Faster CPython at PyCon, part one by cozzyd on Thursday May 11, 2023 @11:24PM (#35911507)
most non-trivial numpy operations require temporaries that require new allocations and copies. Eigen3's design lets you avoid these through clever compilation tricks while remaining high-level.

sometimes numpy can elide those (e.g. why a+=b is faster than a=a+b) but this it not possible in general. Sometimes people use monstrosities like einsum... but I find it more intuitive to just write in C or C++...

In addition to the time spent in allocation / gc / needless copying, the memory footprint can be higher by a factor of a few (or more...).

Re:Faster CPython at PyCon, part one by klyrs on Friday May 12, 2023 @05:51PM (#35922944)
Yep, einsum is included in "doing numpy right." And for what it's worth, it's horrid to use and still won't get around cases like x -> cos(x). I haven't needed the power of eigen for a couple of years, but I appreciate the tip.