[Django] #36977: Cache more expression `output_field` properties

21 views
Skip to first unread message

Django

unread,
Mar 7, 2026, 5:36:30 PMMar 7
to django-...@googlegroups.com
#36977: Cache more expression `output_field` properties
-------------------------------------+-------------------------------------
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 |
-------------------------------------+-------------------------------------
Many expression classes use `@cached_property` on `output_field` to avoid
recomputation, such as
[https://github.com/django/django/blob/0ae0029c2f4d82af937e9632cd5bf13e81e91f98/django/contrib/gis/db/backends/postgis/operations.py#L116-L118
`ST_Polygon`] and
[https://github.com/django/django/blob/0ae0029c2f4d82af937e9632cd5bf13e81e91f98/django/db/models/lookups.py#L162-L164
`Lookup`]. However, the opportunity has been missed in some expression
classes.
--
Ticket URL: <https://code.djangoproject.com/ticket/36977>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 7, 2026, 5:51:29 PMMar 7
to django-...@googlegroups.com
#36977: Cache more expression `output_field` properties
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
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/36977#comment:1>

Django

unread,
Mar 9, 2026, 2:12:43 PMMar 9
to django-...@googlegroups.com
#36977: Cache more expression `output_field` properties
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Elias Stinson):

* cc: Elias Stinson (added)
* needs_better_patch: 0 => 1
* needs_docs: 0 => 1

Comment:

Before I mark the triage as accepted, what exact computed classes will the
patch cache? Just need a bit more info before I can mark this as accepted.
However, I do agree that this should be added if you provide a clear
outline of what exact computed class(es) will be cached, and how you will
modify it. I'll CC myself so I can see if you provide that info, and
furthermore will accept it in that case.
--
Ticket URL: <https://code.djangoproject.com/ticket/36977#comment:2>

Django

unread,
Mar 9, 2026, 3:39:52 PMMar 9
to django-...@googlegroups.com
#36977: Cache more expression `output_field` properties
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Adam Johnson):

See the linked PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/36977#comment:3>

Django

unread,
Mar 9, 2026, 3:41:36 PMMar 9
to django-...@googlegroups.com
#36977: Cache more expression `output_field` properties
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Elias Stinson):

Ok! Will do!
--
Ticket URL: <https://code.djangoproject.com/ticket/36977#comment:4>

Django

unread,
Mar 9, 2026, 5:04:08 PMMar 9
to django-...@googlegroups.com
#36977: Cache more expression `output_field` properties
-------------------------------------+-------------------------------------
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 Elias Stinson):

* cc: Elias Stinson (removed)
* needs_better_patch: 1 => 0
* needs_docs: 1 => 0
* stage: Unreviewed => Ready for checkin

Comment:

After reviewing the PR, I will mark this for checkin, as it is clearly
defined what classes are being optimized, and a pr has already been
created, and has been reviewed! Also, removing myself as CC just because
now it's up to the django maintainers to implement the patch, and no
further involvement from me is needed!
--
Ticket URL: <https://code.djangoproject.com/ticket/36977#comment:5>

Django

unread,
Mar 9, 2026, 5:19:09 PMMar 9
to django-...@googlegroups.com
#36977: Cache more expression `output_field` properties
-------------------------------------+-------------------------------------
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: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted

Comment:

Elias, community triage is welcome (thank you!), but I would advise
tackling fewer issues at first until you get the hang of things. For
instance, this one isn't ready for checkin because there are changes
requested on the PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/36977#comment:6>
Reply all
Reply to author
Forward
0 new messages