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

0 views
Skip to first unread message

Django

unread,
Feb 13, 2026, 6:48:42 PM (3 days 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.

Django

unread,
4:18 AM (19 hours ago) 4:18 AM
to django-...@googlegroups.com
#36927: Optimize Field.deconstruct()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* stage: Unreviewed => Accepted

Comment:

Thanks for the ticket!
--
Ticket URL: <https://code.djangoproject.com/ticket/36927#comment:1>
Reply all
Reply to author
Forward
0 new messages