Skip to content
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

STY: usage of itertools #1018

Open
jklenzing opened this issue Jun 8, 2022 · 1 comment
Open

STY: usage of itertools #1018

jklenzing opened this issue Jun 8, 2022 · 1 comment
Labels
good first issue style An issue or question about the best way of doing things. For example, does this follow PEP-8?
Milestone

Comments

@jklenzing
Copy link
Member

jklenzing commented Jun 8, 2022

Is your feature request related to a problem? Please describe.
There are areas of the code where we have a bunch of nested for loops. This limits the usable space deep in the loop (80-char).

Describe the solution you'd like
Use itertools.product to combine the loops. This is part of the core python package. Functionally, it still works as nested for loops, but the ease of reading is improved.

Describe alternatives you've considered
Leave things as they are.

Additional context
Example:

for version in versions:
for revision in revisions:
for cycle in cycles:

import itertools
a = [1, 2]
b = [3, 4]
c = [5, 6]
for i, j, k in itertools.product(a, b, c):
    print(i, j, k)
@jklenzing jklenzing added the style An issue or question about the best way of doing things. For example, does this follow PEP-8? label Jun 8, 2022
@aburrell
Copy link
Member

aburrell commented Jun 8, 2022

This is more pythonic, so I like it. However, I think there should be a comment above that explains it's basically nested for-loops for ease of reading.

@rstoneback rstoneback added this to the Future milestone Jun 8, 2022
@jklenzing jklenzing modified the milestones: Future, 3.3.0 Release Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue style An issue or question about the best way of doing things. For example, does this follow PEP-8?
Projects
None yet
Development

No branches or pull requests

3 participants