Skip to content

Use list comprehension to join strings #41753

Closed
@MarcoGorelli

Description

@MarcoGorelli

In #41160 , a new pyupgrade feature did some rewrites likes

-    s = "\n".join([_build_option_description(k) for k in keys])
+   s = "\n".join(_build_option_description(k) for k in keys)

However, they then reverted this feature as it was a potential performance regression (asottile/pyupgrade#456).

I think we should revert those changes (though arguably not the entire PR) and add a rule to pandas-dev-flaker about using list comprehensions rather than generators when joining strings

If nobody takes this on earlier, I'll do this on Friday

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code StyleCode style, linting, code_checksPerformanceMemory or execution speed performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions