#32971: Internal Field.check() methods don't need to construct and return lists
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Chris Jerdonek:
Old description:
> I noticed that many of the internal "check()" methods used by `Field`
> subclasses return lists (including the empty list) when they can just
> yield items (or yield nothing). This is because the concrete `check()`
> implementations unpack the return value when constructing a new list. See
> here for one example of such a `check()` method:
> https://github.com/django/django/blob/f331eba6d576752dd79c4b37c41d981daa537fe6/django/db/models/fields/__init__.py#L196-L205
>
> The proposed change, then, would be to change methods like the following
> to yield their items instead of creating and returning a list:
> https://github.com/django/django/blob/f331eba6d576752dd79c4b37c41d981daa537fe6/django/db/models/fields/__init__.py#L243-L254
New description:
I noticed that many of the internal "check()" methods used by `Field`
subclasses return lists (including the empty list) when they can just
yield items (or yield nothing). This is because the concrete `check()`
implementations unpack the return value when constructing a new list. See
here for one example of such a `check()` method:
https://github.com/django/django/blob/f331eba6d576752dd79c4b37c41d981daa537fe6/django/db/models/fields/__init__.py#L196-L205
The proposed change, then, would be to change methods like the following
to yield their items instead of creating and returning a list:
https://github.com/django/django/blob/f331eba6d576752dd79c4b37c41d981daa537fe6/django/db/models/fields/__init__.py#L243-L254
It looks like there are 23 methods in that file with a name starting with
`_check...`.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32971#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.7ee04a73289870dbece34613857695b4%40djangoproject.com.