Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
baca675
Working draft without _source
rhettinger Sep 8, 2017
3a2aa41
Re-use itemgetter() instances
rhettinger Sep 8, 2017
e24ef4b
Speed-up calls to __new__() with a pre-bound tuple.__new__()
rhettinger Sep 8, 2017
49aa967
Add note regarding string interning
rhettinger Sep 8, 2017
c34b444
Remove unnecessary create function wrappers
rhettinger Sep 8, 2017
0c7f163
Minor sync-ups with PR-2736. Mostly formatting and f-strings
rhettinger Sep 8, 2017
5de0b7f
Bring-in qualname/__module fix-ups from PR-2736
rhettinger Sep 8, 2017
ca643f4
Formally remove the verbose flag and _source attribute
rhettinger Sep 8, 2017
e18b92e
Restore a test of potentially problematic field names
rhettinger Sep 8, 2017
0851fc7
Restore kwonly_args test but without the verbose option
rhettinger Sep 8, 2017
3ac1151
Adopt Inada's idea to reuse the docstrings for the itemgetters
rhettinger Sep 8, 2017
b31f063
Neaten-up a bit
rhettinger Sep 8, 2017
deb30a2
Add news blurb
rhettinger Sep 8, 2017
f402cb3
Merge branch 'master' of github.com:python/cpython into optimize-name…
rhettinger Sep 9, 2017
86cef9e
Serhiy pointed-out the need for interning
rhettinger Sep 9, 2017
83b5e93
Jelle noticed as missing f on an f-string
rhettinger Sep 9, 2017
0168317
Add whatsnew entry for feature removal
rhettinger Sep 9, 2017
dadafc0
Accede to request for dict literals instead keyword arguments
rhettinger Sep 9, 2017
483d08c
Leave the method.__module__ attribute pointing the actual location of…
rhettinger Sep 9, 2017
bc6852c
Improve variable names and add a micro-optimization for an non-public…
rhettinger Sep 10, 2017
c897674
Simplify by in-lining reuse_itemgetter()
rhettinger Sep 10, 2017
bd4ea4e
Arrange steps in more logical order
rhettinger Sep 10, 2017
ffb78c9
Save docstring in local cache instead of interning
rhettinger Sep 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Speed-up calls to __new__() with a pre-bound tuple.__new__()
  • Loading branch information
rhettinger committed Sep 8, 2017
commit e24ef4beb1cbb90639af13bc09a367bf54c7a48c
4 changes: 2 additions & 2 deletions Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ def namedtuple(typename, field_names, *, verbose=False, rename=False, module=Non
# Create all the named tuple methods to be added to the class namespace

def create_new():
s = f'def __new__(_cls, {arg_list}): return _tuple.__new__(_cls, ({arg_list}))'
namespace = dict(_tuple=tuple, __name__=f'namedtuple_{typename}')
s = f'def __new__(_cls, {arg_list}): return _tuple_new(_cls, ({arg_list}))'
namespace = dict(_tuple_new=tuple_new, __name__=f'namedtuple_{typename}')
exec(s, namespace)
__new__ = namespace['__new__']
__new__.__doc__ = f'Create new instance of {typename}({arg_list})'
Expand Down