Skip to content

pyupgrade aggressively changing lists to generators #540

@deepyaman

Description

@deepyaman

pyupgrade is changing https://github.com/quantumblacklabs/kedro/blob/0.17.5/kedro/pipeline/node.py#L504 to use a generator instead. I'm not sure/haven't looked into why, but this actually may be a bit slower (tested with a slight modification):

>>> timeit('foo(*[node_inputs[item] for item in node_inputs])', 'foo = lambda *args: None; node_inputs=list(range(1000))', number=100000)
3.4650831540000127
>>> timeit('foo(*(node_inputs[item] for item in node_inputs))', 'foo = lambda *args: None; node_inputs=list(range(1000))', number=100000)
4.6001044469999215

I don't think the performance is a major concern, but maybe pyupgrade shouldn't change this aggressively, if there's no clear benefit (and some people may prefer the list stylistically).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions