#35893: Using list comprehension (instead of a generator) to any/all where the
items are side-effect free is a performance error
-------------------------------------+-------------------------------------
Reporter: john- | Owner: john-parton
parton |
Type: | Status: assigned
Cleanup/optimization |
Component: | Version: dev
contrib.admin |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
When passing a generator to `any()` or `all()`, Python can perform short-
circuit evaluation to avoid needless computation.
Directly passing a list using list-comprehension is generally not
recommended, unless the list-comprehension has a side-effect (for example
calling a method that sets attributes on an object)
There's at least one place in the code-base where it's safe to replace
list comprehension with a generator and get the short-circuit optimization
for "free."
--
Ticket URL: <
https://code.djangoproject.com/ticket/35893>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.