[New-bugs-announce] [issue42699] Use `.join(k for k in g)` instead of `.join([k for k in g])`

Samuel Marks report at bugs.python.org
Sun Dec 20 20:39:34 EST 2020


New submission from Samuel Marks <samuelmarks at gmail.com>:

This is an extremely minor improvement. Rather than create a `list`—using a comprehension—then have it consumed by `.join`, one can skip the list construction entirely.

(I remember this working from at least Python 2.7… probably earlier also)

----------
messages: 383474
nosy: samuelmarks
priority: normal
pull_requests: 22737
severity: normal
status: open
title: Use `.join(k for k in g)` instead of `.join([k for k in g])`
type: performance
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42699>
_______________________________________


More information about the New-bugs-announce mailing list