#32901: BaseForm.__getitem__() does unneeded work in the happy path
-------------------------------------+-------------------------------------
Reporter: Chris | Owner: Chris Jerdonek
Jerdonek |
Type: | Status: assigned
Cleanup/optimization |
Component: Forms | Version: dev
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I noticed that in the "happy path," `BaseForm.__getitem__()` does unneeded
work:
https://github.com/django/django/blob/fa35c8bdbc6aca65d94d6280fa463d5bc7baa5c0/django/forms/forms.py#L150-L164
It can just return `self._bound_fields_cache[name]` at the beginning and
handle `KeyError`, instead of accessing `self.fields` followed by checking
for the presence of `name` in `self._bound_fields_cache` before doing so
each time.
--
Ticket URL: <https://code.djangoproject.com/ticket/32901>
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/052.d4738f651c6b60d1b286922ae3ca556f%40djangoproject.com.