3 ms·
The culprit here is `a_list: Vec<Vec<f64>>`, which means the list of lists is copied as a whole, hence why the rust version is slower. In general, rust is at l
by PartiallyTyped 6y ago
The culprit here is `a_list: Vec<Vec<f64>>`, which means the list of lists is copied as a whole, hence why the rust version is slower.
In general, rust is at least as fast as C or C++, but this seems to be a special case.
- hobofan 6y agoIt's also repeatedly `push`-ing elements into the `Vec`, which will likely lead to repeated allocation and copying. In a case like this were you pretty clearly know the size beforehand you should crate a Vec of the appropriate size with `Vec::reserve`.
- Sukera 6y agoThe julia version also does that though