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

14 views
Skip to first unread message

Django

unread,
Feb 13, 2026, 6:48:42 PMFeb 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,
Feb 16, 2026, 4:18:29 AMFeb 16
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>

Django

unread,
Mar 2, 2026, 3:28:24 PMMar 2
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: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36927#comment:2>

Django

unread,
Mar 8, 2026, 9:20:57 AMMar 8
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: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36927#comment:3>

Django

unread,
Mar 13, 2026, 4:29:20 PMMar 13
to django-...@googlegroups.com
#36927: Optimize Field.deconstruct()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"e779bc7d78cbcadd395d48e5b6b00acea07ce503" e779bc7]:
{{{#!CommitTicketReference repository=""
revision="e779bc7d78cbcadd395d48e5b6b00acea07ce503"
Fixed #36927 -- Optimized Field.deconstruct().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36927#comment:4>
Reply all
Reply to author
Forward
0 new messages