8000 bpo-46841: Move the cache for `LOAD_GLOBAL` inline. by markshannon · Pull Request #31575 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-46841: Move the cache for LOAD_GLOBAL inline. #31575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Merge main and fix duplication of _PyOpcode_InlineCacheEntries table.
  • Loading branch information
markshannon committed Feb 25, 2022
commit c8e38a3ddb7ed8ddd10bb83884bfd2995fef66cb
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Objects/call.c @markshannon
Python/ceval.c @markshannon
Python/compile.c @markshannon
Python/ast_opt.c @isidentical
Lib/test/test_patma.py @brandtbucher
Lib/test/test_peepholer.py @brandtbucher

# Exceptions
Lib/traceback.py @iritkatriel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: 'Build HTML documentation'
run: make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" html
- name: 'Upload'
uses: actions/upload-artifact@v2.2.4
uses: actions/upload-artifact@v2.3.1
with:
name: doc-html
path: Doc/build/html
4 changes: 4 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
stale-pr-label: 'stale'
days-before-stale: 30
days-before-close: -1
ascending: true
operations-per-run: 120

- name: "Check PRs with 'CLA not signed' label"
uses: actions/stale@v4
Expand All @@ -34,3 +36,5 @@ jobs:
close-pr-message: 'Closing this stale PR because the CLA is still not signed.'
days-before-stale: 30
days-before-close: 14
ascending: true
operations-per-run: 120
15 changes: 8 additions & 7 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ For convenience, some of these functions will always return a
.. versionadded:: 3.3


.. c:function:: PyObject* PyErr_SetImportErrorSubclass(PyObject *exception, PyObject *msg, PyObject *name, PyObject *path)

Much like :c:func:`PyErr_SetImportError` but this function allows for
specifying a subclass of :exc:`ImportError` to raise.

.. versionadded:: 3.6


.. c:function:: void PyErr_SyntaxLocationObject(PyObject *filename, int lineno, int col_offset)

Set file, line, and offset information for the current exception. If the
Expand Down Expand Up @@ -320,13 +328,6 @@ an error value).
:mod:`warnings` module and the :option:`-W` option in the command line
documentation. There is no C API for warning control.

.. c:function:: PyObject* PyErr_SetImportErrorSubclass(PyObject *exception, PyObject *msg, PyObject *name, PyObject *path)

Much like :c:func:`PyErr_SetImportError` but this function allows for
specifying a subclass of :exc:`ImportError` to raise.

.. versionadded:: 3.6


.. c:function:: int PyErr_WarnExplicitObject(PyObject *category, PyObject *message, PyObject *filename, int lineno, PyObject *module, PyObject *registry)

Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/reflection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Reflection
See also :c:func:`PyThreadState_GetFrame`.


.. c:function:: int PyFrame_GetBack(PyFrameObject *frame)
.. c:function:: PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)

Get the *frame* next outer frame.

Expand All @@ -42,7 +42,7 @@ Reflection
.. versionadded:: 3.9


.. c:function:: int PyFrame_GetCode(PyFrameObject *frame)
.. c:function:: PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)

Get the *frame* code.

Expand Down
27 changes: 14 additions & 13 deletions Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ PyObject Slots
--------------

The type object structure extends the :c:type:`PyVarObject` structure. The
:attr:`ob_size` field is used for dynamic types (created by :func:`type_new`,
:attr:`ob_size` field is used for dynamic types (created by :func:`type_new`,
usually called from a class statement). Note that :c:data:`PyType_Type` (the
metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its instances (i.e.
type objects) *must* have the :attr:`ob_size` field.
Expand Down Expand Up @@ -2000,6 +2000,17 @@ and :c:type:`PyType_Type` effectively act as defaults.)
For this field to be taken into account (even through inheritance),
you must also set the :const:`Py_TPFLAGS_HAVE_FINALIZE` flags bit.

Also, note that, in a garbage collected Python,
:c:member:`~PyTypeObject.tp_dealloc` may be called from
any Python thread, not just the thread which created the object (if the object
becomes part of a refcount cycle, that cycle might be collected by a garbage
collection on any thread). This is not a problem for Python API calls, since
the thread on which tp_dealloc is called will own the Global Interpreter Lock
(GIL). However, if the object being destroyed in turn destroys objects from some
other C or C++ library, care should be taken to ensure that destroying those
objects on the thread which called tp_dealloc will not violate any assumptions
of the library.

**Inheritance:**

This field is inherited by subtypes.
Expand All @@ -2024,17 +2035,6 @@ and :c:type:`PyType_Type` effectively act as defaults.)
.. versionadded:: 3.9 (the field exists since 3.8 but it's only used since 3.9)


Also, note that, in a garbage collected Python, :c:member:`~PyTypeObject.tp_dealloc` may be called from
any Python thread, not just the thread which created the object (if the object
becomes part of a refcount cycle, that cycle might be collected by a garbage
collection on any thread). This is not a problem for Python API calls, since
the thread on which tp_dealloc is called will own the Global Interpreter Lock
(GIL). However, if the object being destroyed in turn destroys objects from some
other C or C++ library, care should be taken to ensure that destroying those
objects on the thread which called tp_dealloc will not violate any assumptions
of the library.


.. _static-types:

Static Types
Expand Down Expand Up @@ -2440,7 +2440,8 @@ Async Object Structures

PyObject *am_aiter(PyObject *self);

Must return an :term:`awaitable` object. See :meth:`__anext__` for details.
Must return an :term:`asynchronous iterator` object.
See :meth:`__anext__` for details.

This slot may be set to ``NULL`` if an object does not implement
asynchronous iteration protocol.
Expand Down
8 changes: 4 additions & 4 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ Error handling is set by errors which may also be set to ``NULL`` meaning to use
the default handling defined for the codec. Default error handling for all
built-in codecs is "strict" (:exc:`ValueError` is raised).

The codecs all use a similar interface. Only deviation from the following
The codecs all use a similar interface. Only deviations from the following
generic ones are documented for simplicity.


Expand Down Expand Up @@ -1171,7 +1171,7 @@ These are the UTF-16 codec APIs:
``1``, any byte order mark is copied to the output (where it will result in
either a ``\ufeff`` or a ``\ufffe`` character).

After completion, *\*byteorder* is set to the current byte order at the end
After completion, ``*byteorder`` is set to the current byte order at the end
of input data.

If *byteorder* is ``NULL``, the codec starts in native order mode.
Expand Down Expand Up @@ -1302,7 +1302,7 @@ Character Map Codecs

This codec is special in that it can be used to implement many different codecs
(and this is in fact what was done to obtain most of the standard codecs
included in the :mod:`encodings` package). The codec uses mapping to encode and
included in the :mod:`encodings` package). The codec uses mappings to encode and
decode characters. The mapping objects provided must support the
:meth:`__getitem__` mapping interface; dictionaries and sequences work well.

Expand Down Expand Up @@ -1426,7 +1426,7 @@ They all return ``NULL`` or ``-1`` if an exception occurs.
.. c:function:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend)

Split a Unicode string at line breaks, returning a list of Unicode strings.
CRLF is considered to be one line break. If *keepend* is ``0``, the Line break
CRLF is considered to be one line break. If *keepend* is ``0``, the line break
characters are not included in the resulting strings.


Expand Down
14 changes: 12 additions & 2 deletions Doc/c-api/veryhigh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ the same library that the Python runtime is using.
:c:func:`PyRun_SimpleFile`. *filename* is decoded from the filesystem
encoding (:func:`sys.getfilesystemencoding`). If *filename* is ``NULL``, this
function uses ``"???"`` as the filename.
If *closeit* is true, the file is closed before
``PyRun_SimpleFileExFlags()`` returns.


.. c:function:: int PyRun_SimpleString(const char *command)
Expand Down Expand Up @@ -286,8 +288,16 @@ the same library that the Python runtime is using.

.. c:type:: PyFrameObject

The C structure of the objects used to describe frame objects. The
fields of this type are subject to change at any time.
The C structure of the objects used to describe frame objects.

The structure is only part of the internal C API: fields should not be
access directly. Use getter functions like :c:func:`PyFrame_GetCode` and
:c:func:`PyFrame_GetBack`.

Debuggers and profilers can use the limited C API to access this structure.

.. versionchanged:: 3.11
The structure moved to the internal C API headers.


.. c:function:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
Expand Down
16 changes: 7 additions & 9 deletions Doc/howto/descriptor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,14 @@ a pure Python equivalent:
>>> b.g == b['g'] == ('getattr_hook', b, 'g')
True

Note, there is no :meth:`__getattr__` hook in the :meth:`__getattribute__`
code. That is why calling :meth:`__getattribute__` directly or with
``super().__getattribute__`` will bypass :meth:`__getattr__` entirely.

Interestingly, attribute lookup doesn't call :meth:`object.__getattribute__`
directly. Instead, both the dot operator and the :func:`getattr` function
perform attribute lookup by way of a helper function:
Instead, it is the dot operator and the :func:`getattr` function that are
responsible for invoking :meth:`__getattr__` whenever :meth:`__getattribute__`
raises an :exc:`AttributeError`. Their logic is encapsulated in a helper
function:

.. testcode::

Expand Down Expand Up @@ -744,12 +748,6 @@ perform attribute lookup by way of a helper function:
...
AttributeError: 'ClassWithoutGetAttr' object has no attribute 'z'

So if :meth:`__getattr__` exists, it is called whenever :meth:`__getattribute__`
raises :exc:`AttributeError` (either directly or in one of the descriptor calls).

Also, if a user calls :meth:`object.__getattribute__` directly, the
:meth:`__getattr__` hook is bypassed entirely.


Invocation from a class
-----------------------
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,9 @@ Task Object
.. versionchanged:: 3.9
Added the *msg* parameter.

.. versionchanged:: 3.11
The ``msg`` parameter is propagated from cancelled task to its awaiter.

.. _asyncio_example_task_cancel:

The following example illustrates how coroutines can intercept
Expand Down
7 changes: 4 additions & 3 deletions Doc/library/calendar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,10 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is

.. note::

The :meth:`formatweekday` and :meth:`formatmonthname` methods of these two
classes temporarily change the ``LC_TIME`` locale to the given *locale*. Because
the current locale is a process-wide setting, they are not thread-safe.
The constructor, :meth:`formatweekday` and :meth:`formatmonthname` methods
of these two classes temporarily change the ``LC_TIME`` locale to the given
*locale*. Because the current locale is a process-wide setting, they are
not thread-safe.


For simple text calendars this module provides the following functions.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ For example::
according to when an element is first encountered in the left operand
and then by the order encountered in the right operand.

Counter objects support three methods beyond those available for all
Counter objects support additional methods beyond those available for all
dictionaries:

.. method:: elements()
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/configparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ out. Values can also span multiple lines, as long as they are indented deeper
than the first line of the value. Depending on the parser's mode, blank lines
may be treated as parts of multiline values or ignored.

By default, a valid section name can be any string that does not contain '\\n' or ']'.
To change this, see :attr:`ConfigParser.SECTCRE`.

Configuration files may include comments, prefixed by specific
characters (``#`` and ``;`` by default [1]_). Comments may appear on
their own on an otherwise empty line, possibly indented. [1]_
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0