From 844f71b7e4d8b5cdb61f4800ee14a11f3ee9ad15 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 6 Jan 2008 22:11:54 +0000 Subject: Speed-up named tuple's _make() constructor. --- Lib/collections.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/collections.py b/Lib/collections.py index 39b9229..0b86898 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -65,9 +65,9 @@ def namedtuple(typename, field_names, verbose=False): def __new__(cls, %(argtxt)s): return tuple.__new__(cls, (%(argtxt)s)) \n @classmethod - def _make(cls, iterable): + def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new %(typename)s object from a sequence or iterable' - result = tuple.__new__(cls, iterable) + result = new(cls, iterable) if len(result) != %(numfields)d: raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result)) return result \n -- cgit v0.12