[ python-Feature Requests-1541463 ] Optimizations for cgi.FieldStorage methods

SourceForge.net noreply at sourceforge.net
Fri Aug 18 00:52:51 CEST 2006


Feature Requests item #1541463, was opened at 2006-08-16 13:37
Message generated for change (Comment added) made by jimjjewett
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1541463&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Bob Kline (bkline)
Assigned to: Georg Brandl (gbrandl)
Summary: Optimizations for cgi.FieldStorage methods

Initial Comment:
Please add the following optimizations to the
FieldStorage class in cgi.py:

# =================================================

    def keys(self):
        """Dictionary style keys() method."""
        if self.list is None:
            raise TypeError, "not indexable"
        return {}.fromkeys([item.name for item in
self.list]).keys()

    def __nonzero__(self):
        """Support for efficient test of instance"""
        return self.list and True or False

# =================================================

The __nonzero__ method is new, and keys() method is a
replacement for code which built the list of unique
fields names by hand, and which took several orders of
magnitude longer to perform.

If you need me to post this as a patch against a
certain version, let me know.

----------------------------------------------------------------------

Comment By: Jim Jewett (jimjjewett)
Date: 2006-08-17 18:52

Message:
Logged In: YES 
user_id=764593

Why are you creating a dictionary just to take its keys?

Is there a reason the keys method can't just return

[item.name for item in self.list] 

directly?

----------------------------------------------------------------------

Comment By: Bob Kline (bkline)
Date: 2006-08-16 13:52

Message:
Logged In: YES 
user_id=291529

I didn't realize this interface would strip leading blanks
from lines.  Patch submitted to get around this problem.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1541463&group_id=5470


More information about the Python-bugs-list mailing list