#30563: Optimize django.forms.widgets.Media.__add__.
--------------------------------------+------------------------------------
     Reporter:  David Dorothy         |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Forms                 |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:  media                 |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by David Dorothy):

 Replying to [comment:2 Matthias Kestenholz]:
 > I wonder how many distinct lists of assets you have? In the example
 above you're merging the same list 100'000 times.
 >

 I encountered this issue when using the StreamField from Wagtail
 (http://wagtail.io) where we have a use case that dictates creating
 significant nesting of common forms to be able to edit the stream of
 output. To be fair, our use case of Wagtail is beyond the expected use of
 Wagtail as the performance is poor. I have created a customization that
 helps prevent the performance issue in Wagtail by declaring all stream
 objects as classes that only generate their forms once per object. This
 workaround resolves the wagtail performance issue (for our needs) but not
 the `Media.__add__` performance issue in Django.

 I may be able to share my code if that will help. I do not personally own
 that code though so I'd have to get permission.

 We have nested classes of up to four or five levels deep and about 70
 unique classes. But because of the way it works the number of forms
 generated grows exponentially. Since these are all the same classes though
 the number of distinct lists is limited that I think your de-duplication
 idea would probably work.

 I'm not sure whether your code works or not because I actually short
 circuited in a subclass of a wagtail class to overcome the issue. I might
 be able to replace the Django Media class via monkey patching with a
 different version to test but I'm not sure. If I get some time to try this
 out I'll post a followup comment and try to include some sample code or
 possibly a patch with some matching tests. Not sure how much time I will
 be able to dedicate to this.

 Thanks for looking into this issue.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30563#comment:4>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.61ed47ab91c652a00030351fdbc51553%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to