#15625: MultiValueDictKeyError exception has large performance penalty
----------------------------+---------------------------
 Reporter:  margieroginski  |         Owner:  nobody
   Status:  new             |     Milestone:
Component:  Uncategorized   |       Version:  1.2
 Keywords:                  |  Triage Stage:  Unreviewed
Has patch:  0               |
----------------------------+---------------------------
 I am seeing a large potential performance penalty due to a string argument
 representing the entire POST dict getting created when a key is not found
 in the POST dict.

 In datastructures.py, in class !MultiValueDict, {{{__getitem__()}}} has
 the following code:

 {{{
         try:
             list_ = super(!MultiValueDict, self).__getitem__(key)
         except !KeyError:
             raise !MultiValueDictKeyError("Key %r not found in %r" % (key,
 self))
 }}}

 During form validation, this exception is raised for each field/key not
 found in the POST dict.  If the POST dict is very large, the %r associated
 with self is very large and can have a very significant time penalty.  In
 a case where I had 300 of these exceptions, the time penalty of creating
 this string was almost 2 seconds.

 It is not that unusual to have POST keys missing that are checked in this
 way.  Here are a few of the common cases I've seen:

 1. checkboxes that are unchecked
 2. url arguments that could be POSTED but which are omitted
 3. fields that are dynamic - ie, they may not be there unless some client
 code creates them.

 Do we need to provide a string argument at all in this case, given the
 potential time penalty and the frequency of getting values from the POST
 dict?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15625>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to