Opened 9 years ago

Closed 9 years ago

#25322 closed Cleanup/optimization (fixed)

Lazily compile core.validators regular expressions

Reported by: Jonas Haag Owned by: nobody
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Avoiding a lot of slow re.compile() calls at the module-level in django.core.validators can save a few hundred milliseconds when importing the module for the first time, which is a significant speedup to the django-admin command (and possibly other places as well).

Benchmarks using time django-admin:

  • master:
    • Python 2: 0.56 real 0.49 user 0.06 sys
    • Python 3: 0.56 real 0.52 user 0.03 sys
  • patched:
    • Python 2: 0.26 real 0.20 user 0.05 sys
    • Python 3: 0.35 real 0.31 user 0.03 sys

PR

Change History (2)

comment:1 by Tim Graham, 9 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 2bb1027d:

Fixed #25322 -- Lazily compiled core.validators regular expressions.

This speeds up import of 'django.core.validators' which can save a
few hundred milliseconds when importing the module for the first
time. It can be a significant speedup to the django-admin command.

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