itertools icon indicating copy to clipboard operation
itertools copied to clipboard

Fuse iterators in InterleaveShortest

Open phimuemue opened this issue 1 year ago • 5 comments

In my book, InterleaveShortest should not produce more items than Interleave, but so far it did for unfused source iterators.

This PR brings InterleaveShortest in line with Interleave. The documentation already (incorrectly) stated that InterleaveShortest is fused.

Related to #533.

phimuemue avatar Feb 08 '24 12:02 phimuemue

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (6814180) 94.38% compared to head (d8f7f59) 94.28%. Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #872      +/-   ##
==========================================
- Coverage   94.38%   94.28%   -0.11%     
==========================================
  Files          48       48              
  Lines        6665     6665              
==========================================
- Hits         6291     6284       -7     
- Misses        374      381       +7     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 08 '24 12:02 codecov[bot]

I started an investigation ("blame" in the web pages of our code is even more powerful than I thought (for each line, we can have navigate its history)): In #31 it was added and was actually fused. Then the commit that is interesting us here is https://github.com/rust-itertools/itertools/commit/beaf3955b51f5a5a2c5861d34ebd591736377b84 (by bluss, he missed one comment in this "unfuse" commit that you found).

Philippe-Cholet avatar Feb 08 '24 12:02 Philippe-Cholet

I started an investigation ("blame" in the web pages of our code is even more powerful than I thought (for each line, we can have navigate its history)): In #31 it was added and was actually fused. Then the commit that is interesting us here is beaf395 (by bluss, he missed one comment in this "unfuse" commit that you found).

I'm fine with either unfused or fused, but I'd vote for uniform behavior. Not sure if we have a general guideline regarding fusedness, though.

phimuemue avatar Feb 08 '24 13:02 phimuemue

I'm fine with either unfused or fused, but I'd vote for uniform behavior. Not sure if we have a general guideline regarding fusedness, though.

I agree. I think it would be great to have a clear guideline about fusedness. And maybe better tests about (un)fusedness. I'm not sure all the iterators behave correctly in that regard (and have correct documentation). It's not very high on my TODO list though as I'd rather triage/complete old issues/PRs and work on fold specializations and maybe_/Try to eventually move to use const-generics.

Philippe-Cholet avatar Feb 08 '24 13:02 Philippe-Cholet

I'm gonna make an issue about fusedness to see opened issues and PRs related to it, clarify the situation (like make a guideline) and eventually make a TODO list about all this.

Philippe-Cholet avatar Feb 08 '24 13:02 Philippe-Cholet