#32840: Micro-optimisation possibility in Field.get_col
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: nobody
Type: | Status: new
Cleanup/optimization |
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 Carlton Gibson):
* stage: Unreviewed => Accepted
Comment:
Hi Keryn, thanks. I'm going to provisionally Accept this to let
Mariusz/Simon have a look at it in PR.
I wonder if we need the initial conditional at all... 🤔
Untested, but same idea I think:
{{{
def get_col(self, alias, output_field=None):
if alias != self.model._meta.db_table or (output_field and
output_field != self):
from django.db.models.expressions import Col
return Col(alias, self, output_field or self)
else:
return self.cached_col
}}}
> I'm purposefully avoiding making further investigation/judgement about
whether output_field != self is itself necessary, because it's ostensibly
possible for a custom output_field to be provided which has the same
creation_counter + model and I don't know how likely that is.
Yes.
--
Ticket URL: <https://code.djangoproject.com/ticket/32840#comment:1>
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/067.ac5d0b5a37298f85a9ee772007ac7b0b%40djangoproject.com.