| Graham Dumpleton (JIRA) 2006-10-26, 7:12 am |
| [ http://issues.apache.org/jira/brows...HON-93?page=all ]
Graham Dumpleton reopened MODPYTHON-93:
---------------------------------------
Assignee: Graham Dumpleton (was: Jim Gallacher)
In response to question about dictionary like abilities on mailing list, I actually had my first good look at what the performance optimisation changes did. Previously I only looked at just the bit I thought mattered to the Trac issue. Having done this, I
notice there are actually some problems in the code. Specifically, if add_field() is used after the first time the 'dictionary' attribute is accessed, then the new field doesn't actually get put in the dictionary and therefore isn't visible to __getitem_
_(), has_key() etc. In other words, the 'dictionary' gets set to a snapshot of 'list' and isn't updated there after. I also note that changes which introduced the method add_field() aren't reflected in documentation either.
I'll spend some time reviewing the code and fixing things up. I might also make the 'dictionary' attribute a private attribute and perhaps look at direct changes to 'list' being automatically reflected in any index somehow. In respect of 'dictionary' I wa
nt to hide it so we avoid problems in the future like in Trac where they effectively delved into the implementation, making it hard to make changes.
> Improve util.FieldStorage efficiency
> ------------------------------------
>
> Key: MODPYTHON-93
> URL: http://issues.apache.org/jira/browse/MODPYTHON-93
> Project: mod_python
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.2.7
> Reporter: Jim Gallacher
> Assigned To: Graham Dumpleton
> Priority: Minor
> Fix For: 3.3
>
> Attachments: modpython325_util_py_dict.patch
>
>
> Form fields are saved as a list in a FieldStorage class instance. The class implements a __getitem__ method to provide dict-like behaviour. This method iterates over the complete list for every call to __getitem__. Applications that need to access all
the fields when processing the form will show O(n^2) behaviour where n == the number of form fields. This overhead could be avoided by creating a dict (to use as an index) when the FieldStorage instance is created.
> Mike Looijmans has been investigating StringField and Field as well. It is probably reasonable to include information on his work in this issue as well, so that we can consider all of these efficiency issues in toto.
|