quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Graham Dumpleton (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (MODPYTHON-93) Improve util.FieldStorage efficiency
Date Tue, 24 Oct 2006 05:54:18 GMT
     [ http://issues.apache.org/jira/browse/MODPYTHON-93?page=all ]

Graham Dumpleton resolved MODPYTHON-93.

    Resolution: Fixed

I have looked at the code for this again and to somehow accommodate older versions of Trac
is only going to introduce horrible little hacks in mod_python that we don't need, so it just
isn't worth the trouble to try and support the older versions. People will simply need to
upgrade to at least Trac 0.10.0 if they want to use mod_python 3.3.

If the hacks were done, there would be two parts to it. The first is that Trac derives from
util.FieldStorage and adds a __setitem__() method. This would need to be overridden from the
base class by replacing it with add_field(). 

  def __init__(self, ...):
    self.__setitem__ = self.add_field

It has to be done in the constructor and not just as a method, as doing it as a method means
derived class overrides it. At that point in the constructor, derived class one is in place
and so we effectively replace it.

The second part would be more difficult and why it isn't worth the trouble. The problem here
is that although the derived class adds __setitem__(), it doesn't itself use it in the derived
class constructor. Instead, it does the nasty thing of accessing the base class 'list' attribute
directly, thereby duplicating the same code as in __setitem__() that we need to replace. The
only way around this nastiness would be for the base class to override the 'append()' method
of the 'list' attribute itself and do extra special magic to check for arguments of the old
style and change things on the fly, updating the associated index attribute as well. This
is just all too messy and magic and would surely come back and bite us.

In summary, not worth the trouble. Trac people will just have to upgrade.

> 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: Jim Gallacher
>            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.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message