diff options
author | Raymond Hettinger <python@rcn.com> | 2008-01-06 22:11:54 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-01-06 22:11:54 (GMT) |
commit | 844f71b7e4d8b5cdb61f4800ee14a11f3ee9ad15 (patch) | |
tree | 395af24c20237ef4627e9cfd330a3e1021688430 /Lib/collections.py | |
parent | 35f8861386794a823dfdbee3035f8ef00f0deddd (diff) | |
download | cpython-844f71b7e4d8b5cdb61f4800ee14a11f3ee9ad15.zip cpython-844f71b7e4d8b5cdb61f4800ee14a11f3ee9ad15.tar.gz cpython-844f71b7e4d8b5cdb61f4800ee14a11f3ee9ad15.tar.bz2 |
Speed-up named tuple's _make() constructor.
Diffstat (limited to 'Lib/collections.py')
-rw-r--r-- | Lib/collections.py | 4 |
1 files 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 |