[Django] #36927: Optimize Field.deconstruct()

0 views
Skip to first unread message

Django

unread,
Feb 13, 2026, 6:48:42 PM (18 hours ago) Feb 13
to django-...@googlegroups.com
#36927: Optimize Field.deconstruct()
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: | Status: assigned
Cleanup/optimization |
Component: Database | Version: dev
layer (models, ORM) |
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 profiled a subset of Django’s test suite (`runtests.py --parallel 1
model* queries expressions*`) with cProfile and found that
`Field.deconstruct()` was the function in Django with the largest time
consumed inside itself (0.123s of 7.843 total, or 1.6%).

It can be optimized by flattening its main loop for constructing keyword
arguments and by performing fewer string comparisons for the path.
--
Ticket URL: <https://code.djangoproject.com/ticket/36927>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages