Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02d7b9c

Browse files
Merge branch 'main' into pep688fix
2 parents 5536853 + 01cc9c1 commit 02d7b9c

23 files changed

+542
-435
lines changed

Doc/whatsnew/3.12.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,9 @@ inspect
342342
(Contributed by Thomas Krennwallner in :issue:`35759`.)
343343

344344
* The performance of :func:`inspect.getattr_static` has been considerably
345-
improved. Most calls to the function should be around 2x faster than they
346-
were in Python 3.11. (Contributed by Alex Waygood in :gh:`103193`.)
345+
improved. Most calls to the function should be at least 2x faster than they
346+
were in Python 3.11, and some may be 6x faster or more. (Contributed by Alex
347+
Waygood in :gh:`103193`.)
347348

348349
pathlib
349350
-------
@@ -597,7 +598,7 @@ typing
597598
:func:`runtime-checkable protocols <typing.runtime_checkable>` has changed
598599
significantly. Most ``isinstance()`` checks against protocols with only a few
599600
members should be at least 2x faster than in 3.11, and some may be 20x
600-
faster or more. However, ``isinstance()`` checks against protocols with seven
601+
faster or more. However, ``isinstance()`` checks against protocols with fourteen
601602
or more members may be slower than in Python 3.11. (Contributed by Alex
602603
Waygood in :gh:`74690` and :gh:`103193`.)
603604

Include/internal/pycore_compile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ PyAPI_FUNC(PyObject*) _PyCompile_CodeGen(
9797
PyObject *ast,
9898
PyObject *filename,
9999
PyCompilerFlags *flags,
100-
int optimize);
100+
int optimize,
101+
int compile_mode);
101102

102103
PyAPI_FUNC(PyObject*) _PyCompile_OptimizeCfg(
103104
PyObject *instructions,

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ struct _Py_global_strings {
335335
STRUCT_FOR_ID(code)
336336
STRUCT_FOR_ID(command)
337337
STRUCT_FOR_ID(comment_factory)
338+
STRUCT_FOR_ID(compile_mode)
338339
STRUCT_FOR_ID(consts)
339340
STRUCT_FOR_ID(context)
340341
STRUCT_FOR_ID(cookie)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/argparse.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,21 +345,22 @@ def _format_usage(self, usage, actions, groups, prefix):
345345
def get_lines(parts, indent, prefix=None):
346346
lines = []
347347
line = []
348+
indent_length = len(indent)
348349
if prefix is not None:
349350
line_len = len(prefix) - 1
350351
else:
351-
line_len = len(indent) - 1
352+
line_len = indent_length - 1
352353
for part in parts:
353354
if line_len + 1 + len(part) > text_width and line:
354355
lines.append(indent + ' '.join(line))
355356
line = []
356-
line_len = len(indent) - 1
357+
line_len = indent_length - 1
357358
line.append(part)
358359
line_len += len(part) + 1
359360
if line:
360361
lines.append(indent + ' '.join(line))
361362
if prefix is not None:
362-
lines[0] = lines[0][len(indent):]
363+
lines[0] = lines[0][indent_length:]
363364
return lines
364365

365366
# if prog is short, follow it with optionals or positionals

Lib/inspect.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,8 +1794,9 @@ def _check_class(klass, attr):
17941794
return entry.__dict__[attr]
17951795
return _sentinel
17961796

1797-
def _shadowed_dict(klass):
1798-
for entry in _static_getmro(klass):
1797+
@functools.lru_cache()
1798+
def _shadowed_dict_from_mro_tuple(mro):
1799+
for entry in mro:
17991800
dunder_dict = _get_dunder_dict_of_class(entry)
18001801
if '__dict__' in dunder_dict:
18011802
class_dict = dunder_dict['__dict__']
@@ -1805,6 +1806,9 @@ def _shadowed_dict(klass):
18051806
return class_dict
18061807
return _sentinel
18071808

1809+
def _shadowed_dict(klass):
1810+
return _shadowed_dict_from_mro_tuple(_static_getmro(klass))
1811+
18081812
def getattr_static(obj, attr, default=_sentinel):
18091813
"""Retrieve attributes without triggering dynamic lookup via the
18101814
descriptor protocol, __getattr__ or __getattribute__.

0 commit comments

Comments
 (0)