#36927 assigned Cleanup/optimization

Optimize Field.deconstruct()

Reported by: Adam Johnson Owned by: Adam Johnson
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top