summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-12-18 22:21:27 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-12-18 22:21:27 (GMT)
commit8777bcae2749099b6ea3ac35f079bfa3df470a78 (patch)
treecb33553ce806b85061ef44ba705bbc81c0c8d233 /Doc/library
parent0423698bc3c0c09dd82f7ad2ce3c7bc6a0cae851 (diff)
downloadcpython-8777bcae2749099b6ea3ac35f079bfa3df470a78.zip
cpython-8777bcae2749099b6ea3ac35f079bfa3df470a78.tar.gz
cpython-8777bcae2749099b6ea3ac35f079bfa3df470a78.tar.bz2
Simplify and speedup _asdict() for named tuples.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/collections.rst4
1 files changed, 2 insertions, 2 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 75aa55e..5fcb293 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -394,9 +394,9 @@ Example::
def __repr__(self):
return 'Point(x=%r, y=%r)' % self
- def _asdict(self):
+ def _asdict(t):
'Return a new dict which maps field names to their values'
- return dict(zip(('x', 'y'), self))
+ return {'x': t[0], 'y': t[1]}
def _replace(self, **kwds):
'Return a new Point object replacing specified fields with new values'