by gorg_dc · 4y ago · 0 comments
The code itself looks slow and barely readable. A lot of for loops, few named functions. It needs a very strong refactoring to work properly with numpy. That should be done first, instead of pulling up the RuStIsFast card. It is not surprising that the results were not so great as expected.
In general, the article is too long to be properly understood...
The most obvious (to me) is the constant indexing into pigs. It was hit on in the article (and gave a 25% increase in speed), yet I don't think the author went far enough in elimination.
Pushing the pig_j lookup up into the "for j" scope instead of computing it on each inner loop would have likely saved a large number of the lookups.
In fact, I'd guess that'd be one of the optimizations that rust pulls out. Python is far less likely to pull those sorts of optimizations.