3 ms·
Not the point of the article, but the Python version reads the file twice. Once to get the total line count and again to write out the chosen lines. The Rust ve
by 0cf8612b2e1e 2y ago
Not the point of the article, but the Python version reads the file twice. Once to get the total line count and again to write out the chosen lines. The Rust version proceeds with a single read of the source file.
- ShangBrol 2y agoYep... and it took the algorithm that will look more complicated for the Rust implementation. The premise was "Rust is fast; Python is easy" and that had to be proven :-( I'm sure a Rust version with counting lines won't have any performance advantage... and is easy to write and quite nice to read.