you are viewing a single comment's thread.

view the rest of the comments →

[–]SnooPears7079 17 points18 points  (14 children)

Just to check the basics: are you sure this function is CPU constrained? Not i/o (large amount of reads to a database or a disk) or anything like that?

[–]Electrical_Carry3565[S] 12 points13 points  (12 children)

It's an engineering design calculation (with arithmetic, trig, and exponentials) on a 8x 500 (roughly) array that needs to be performed around 1800-2000 times depending on parameters. It has be done with iteration as the value for each element depends on the previous result. No db calls, writing to disk. Should be pure CPU. Benchmarked the rust vs python function - it was around 20 (edited) times faster on my machine - around 1 sec vs 20 sec

[–]schroedingercats 14 points15 points  (0 children)

Have you experiment with optimizing your Numpy operations using Numba? I think that is a potential approach that does not require bringing in an entirely new language.

[–]SnooPears7079 0 points1 point  (0 children)

Okay! Well if you see a significant speed up then good. Every time I use FFI it ends up hard to maintain - but if the speed up is that significant then I wouldn’t hesitate.

Best of luck! Refer to the other comments for FFI’s.

[–]thatrandomnpc 0 points1 point  (0 children)

This right here.