summaryrefslogtreecommitdiffstats
path: root/Lib/collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-12-14 19:19:59 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-12-14 19:19:59 (GMT)
commit07ae83f8400702a78825204751604b98b6f69c65 (patch)
tree857a958d537304f4a4709e70b5a31c2352ed1619 /Lib/collections.py
parentadbda844d0782a64a278561f08bdf7b0d8218bdb (diff)
downloadcpython-07ae83f8400702a78825204751604b98b6f69c65.zip
cpython-07ae83f8400702a78825204751604b98b6f69c65.tar.gz
cpython-07ae83f8400702a78825204751604b98b6f69c65.tar.bz2
Faster and simpler _replace() method
Diffstat (limited to 'Lib/collections.py')
-rw-r--r--Lib/collections.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/collections.py b/Lib/collections.py
index c3173db..be4d4fd 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -71,7 +71,7 @@ def namedtuple(typename, field_names, verbose=False):
return dict(zip(%(field_names)r, self)) \n
def _replace(self, **kwds):
'Return a new %(typename)s object replacing specified fields with new values'
- return %(typename)s(**dict(zip(%(field_names)r, self), **kwds)) \n\n''' % locals()
+ return %(typename)s(*map(kwds.get, %(field_names)r, self)) \n\n''' % locals()
for i, name in enumerate(field_names):
template += ' %s = property(itemgetter(%d))\n' % (name, i)
if verbose: