#35998: Add caching to urlize
-------------------------------------+-------------------------------------
     Reporter:  Sarah Boyce          |                     Type:
                                     |  Cleanup/optimization
       Status:  new                  |                Component:  Template
                                     |  system
      Version:  5.1                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 `urlize` will checks every word for whether it is a url (and then updates
 the url to be a html link)
 We can add some form of caching so that it doesn't repeat the checks on
 the same "word"

 PR: https://github.com/django/django/pull/18665

 Benchmarks:

 Before:
 {{{
 >>> import cProfile
 >>> from django.template.defaultfilters import urlize
 >>> cProfile.run("urlize('Django. ' * 1_000)")
          61048 function calls (59047 primitive calls) in 0.030 seconds
 }}}
 After:
 {{{
 >>> import cProfile
 >>> from django.template.defaultfilters import urlize
 >>> cProfile.run("urlize('Django. ' * 1_000)")
          3783 function calls (3702 primitive calls) in 0.005 seconds
 }}}

 PR to add benchmark to django-asv: https://github.com/django/django-
 asv/pull/91
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35998>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070193b5f1d452-7349763d-0dde-42b0-948e-2dc8ed31cadb-000000%40eu-central-1.amazonses.com.

Reply via email to