-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permutations unnecessarily complex? #747
Comments
I agree it's quite complex (but the states are clear thanks to the type system). It's probably because of this complexity that the size hint was incomplete until I fixed it. Do you want me to investigate changes further? |
I just wanted to take time to appreciate what's currently done. Each stateDiagram-v2
classDef rust color:orange
state k_eq_0 <<choice>>
k_eq_0: k == 0 ?
state enough <<choice>>
enough: Enough values ?
state full <<choice>>
full: pool.get_next() ?
state end <<choice>>
end: The end ?
[*]
[*] --> k_eq_0
k_eq_0 --> enough: No
k_eq_0 --> CompleteStart: Yes
enough --> [*]: No
enough --> StartUnknownLen: Yes
CompleteStart --> [*]: NO item
StartUnknownLen --> OngoingUnknownLen: advance
full --> OngoingUnknownLen: No
full --> CompleteStart: Yes, then advance X times...
OngoingUnknownLen --> full: advance
OngoingUnknownLen --> OngoingUnknownLen: item
CompleteStart --> CompleteOngoing: advance
CompleteOngoing --> CompleteOngoing: item
CompleteOngoing --> end: advance
end --> CompleteOngoing: No, mostly
end --> CompleteStart: Yes, a single time
class CompleteStart, StartUnknownLen, OngoingUnknownLen, CompleteOngoing rust
Once loaded, we are in |
Now in master...Philippe-Cholet:itertools:permutations-states , I have
Maybe we can simplify this state further. The main commit has 80 additions and 143 deletions: nice simplification IMO. Updated mermaid diagramstateDiagram-v2
classDef rust color:orange
state enough <<choice>>
enough: Enough values ?
state k0 <<choice>>
k0: k == 0 ?
state full <<choice>>
full: pool.get_next() ?
state end <<choice>>
end: The end ?
[*] --> enough
enough --> [*]: No
enough --> Start: Yes
Start --> k0: next
k0 --> [*]: Yes
k0 --> Ongoing: No
full --> Ongoing: No
full --> Complete: Yes, then advance X times...
Ongoing --> full: next
Complete --> end: next
end --> Complete: No
end --> [*]: Yes
class Start, Ongoing, Complete rust
|
master...Philippe-Cholet:itertools:permutations-states
I'm not sure it's better than a more verbose structure, but it's definitely possible. EDIT: Previous c17761a and 486b348 about |
@phimuemue Since you are around, I put a little remainder here. |
Hi @Philippe-Cholet, I appreciate that you want to tackle the problem. I tried to review your commits, and I think most of it is really good. Unfortunately I cannot point my finger at the exact places, but I think I've lost track of the possible states. It surely does not help that I'm not intricately familiar with the As much as I'd love to answer with "yeah, I saw and understood this", I can't offer a more thorough review at the moment. |
@phimuemue Destroy the enum I really prefer
I think we should only keep the first 3 commits and simply discard the rest. The first and third are basic. The second that merges |
Hi @Philippe-Cholet, sounds very reasonable. |
During my review of #739, I found
Permutations
quite complex.As of now, it has four different states:
StartUnknownLen
,OngoingUnknownLen
,Complete
andEmpty
. Its cousinCombinations
, on the other hand, only has fieldsfirst
,pool
,indices
.My gut feeling is that
Permutations
could be massaged into a simpler form that more resembles the one ofCombinations
.@Philippe-Cholet Since you studied that code, can I have your two cents on this?
The text was updated successfully, but these errors were encountered: