3 ms·
> Rust’s iterators are famous for how well they optimize Perhaps famous for how well they optimize away the extrinsic overhead of the iterator concept. Not rea
by dundarious 2y ago
> Rust’s iterators are famous for how well they optimize
Perhaps famous for how well they optimize away the extrinsic overhead of the iterator concept. Not really famous for how well they optimize compared to just writing the loop and iterate code naively with indices or what have you.
And the latter makes it far easier to adapt to use SIMD, sentinel values, etc.
Please avoid implying that Rust has the objectively best tradeoffs for all situations. (See how annoying it is to be on the receiving end of condescension?)
- inferiorhuman 2y agoNot really famous for how well they optimize compared to just writing the loop and iterate code naively with indices or what have you. Sure they are. The loop will have to bounds check at each iteration, the iterator won't necessarily have to. Collect may save on the number of allocations, etc, etc.
- dundarious 2y agoNeither of those are intrinsic issues.
- inferiorhuman 2y agoSo?
- dundarious 2y agoSo why compare it against an artificially hobbled alternative and say "that's the awesome power of Rust!" when it does a bit better. Compare it against an alternative that is not hobbled with extrinsic issues.