Commit c4315640 authored by Raymond Hettinger's avatar Raymond Hettinger

Speed-up named tuple's _make() constructor.

parent 4186db34
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment