unpacked-list-comprehension (UP027)#
Derived from the pyupgrade linter.
Warning: This rule is deprecated and will be removed in a future release.
Fix is always available.
Deprecation#
There's no evidence that generators are meaningfully faster than list comprehensions when combined with unpacking.
What it does#
Checks for list comprehensions that are immediately unpacked.
Why is this bad?#
There is no reason to use a list comprehension if the result is immediately unpacked. Instead, use a generator expression, which avoids allocating an intermediary list.
Example#
Use instead: