[Python-checkins] r58218 - in python/trunk: Lib/cgi.py Misc/NEWS
georg.brandl
python-checkins at python.org
Thu Sep 20 18:06:07 CEST 2007
Author: georg.brandl
Date: Thu Sep 20 18:06:07 2007
New Revision: 58218
Modified:
python/trunk/Lib/cgi.py
python/trunk/Misc/NEWS
Log:
Patch #1541463: optimize performance of cgi.FieldStorage operations.
Modified: python/trunk/Lib/cgi.py
==============================================================================
--- python/trunk/Lib/cgi.py (original)
+++ python/trunk/Lib/cgi.py Thu Sep 20 18:06:07 2007
@@ -607,31 +607,27 @@
"""Dictionary style keys() method."""
if self.list is None:
raise TypeError, "not indexable"
- keys = []
- for item in self.list:
- if item.name not in keys: keys.append(item.name)
- return keys
+ return list(set(item.name for item in self.list))
def has_key(self, key):
"""Dictionary style has_key() method."""
if self.list is None:
raise TypeError, "not indexable"
- for item in self.list:
- if item.name == key: return True
- return False
+ return any(item.name == key for item in self.list)
def __contains__(self, key):
"""Dictionary style __contains__ method."""
if self.list is None:
raise TypeError, "not indexable"
- for item in self.list:
- if item.name == key: return True
- return False
+ return any(item.name == key for item in self.list)
def __len__(self):
"""Dictionary style len(x) support."""
return len(self.keys())
+ def __nonzero__(self):
+ return bool(self.list)
+
def read_urlencoded(self):
"""Internal: read data in query string format."""
qs = self.fp.read(self.length)
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Thu Sep 20 18:06:07 2007
@@ -260,6 +260,8 @@
Library
-------
+- Patch #1541463: optimize performance of cgi.FieldStorage operations.
+
- Decimal is fully updated to the latest Decimal Specification (v1.66).
- Bug #1153: repr.repr() now doesn't require set and dictionary items
More information about the Python-checkins
mailing list