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

[CodeStyle] Use itertools.product reorganize deep nested loops #61229

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Jan 26, 2024

PR types

Others

PR changes

Others

Description

使用 itertools.product 重新组织深层循环,减少缩进,提高格式化后代码可读性

比如

for i in a:
    for j in b:
        for k in c:
            loop_body(i, j, k)

# 可改写为
for i, j, k in product(a, b, c):
    loop_body(i, j, k)

仅 5 层及以上循环修改,低于 5 层在可接受范围内,无需修改

PCard-66972

@SigureMo SigureMo requested a review from gouzil January 26, 2024 14:54
gouzil
gouzil previously approved these changes Jan 26, 2024
Copy link
Member

@gouzil gouzil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SigureMo SigureMo merged commit 96a839d into PaddlePaddle:develop Jan 27, 2024
29 of 30 checks passed
@SigureMo SigureMo deleted the codestyle/use-itertools-product-reorganize-deep-nested-loops branch January 27, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants