3 ms·
rust has concept of references, maybe it was referring to its particular implementation of the problem
by iExploder 5y ago
rust has concept of references, maybe it was referring to its particular implementation of the problem
- efaref 5y agoThe implementations for Rust and Julia are different in a way that means the comparison is not really apples-to-apples. The Julia implementation replaces the input list with a Julia object, which is of course trivial for Julia to iterate over. The Rust implementation is asked to convert the list-of-list-of-floats back to Python types, and then back into Rust types. Of course converting 100M floats back and forth is going to take a non-trivial amount of time. The equivalent in Rust would be to wrap the return value in a PyObject that contains the Rust `Vec<Vec<f64>>`, and the Rust code could then just iterate that directly. It would even be made safe without the GIL as you'd implement your own mutex on the Rust side if you wanted it to be mutable. If you do this then it runs in about 1.2s on my laptop.