#27974: Degraded performance when rendereing ChoiceField with lots of options 
and
DEBUG=True
------------------------------------------------+------------------------
               Reporter:  karyon                |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Template system       |        Version:  1.11
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 One ChoiceField with 1k options took 6s instead of 0.5s after updating to
 django 1.11 with DEBUG=True.

 apollo13 created a reduced test case:


 {{{
     import django
     from django.conf import settings

     settings.configure(DEBUG=True)
     django.setup()


     from django.forms import Form, Select, ChoiceField


     class TestForm(Form):
         test = ChoiceField(widget=Select, choices=map(lambda x: (str(x),
 str(x)), range(1000)))


     print(TestForm())
 }}}

 and the following test


 {{{
 strace python3 test.py 2>&1|grep attr|wc
     1001    4004  120120
 }}}

 shows that
 
[https://github.com/django/django/blob/master/django/forms/templates/django/forms/widgets/attrs.html
 this file] is read 1k times. It seems like the caching of the include tag
 inside loops does not work with nested includes. apollo13 investigated
 further.

--
Ticket URL: <https://code.djangoproject.com/ticket/27974>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.edf447014d3057420b7f556b484160d3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to