| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 00d73ca commit bae415a
17 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -887,15 +887,15 @@ because the :ref:`call protocol <call>` takes care of recursion handling. | |||
| 887 | 887 | depth limit. | |
| 888 | 888 | ||
| 889 | 889 | .. versionchanged:: 3.9 | |
| 890 | - This function is now also available in the limited API. | ||
| 890 | + This function is now also available in the :ref:`limited API <limited-c-api>`. | ||
| 891 | 891 | ||
| 892 | 892 | .. c:function:: void Py_LeaveRecursiveCall(void) | |
| 893 | 893 | ||
| 894 | 894 | Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each | |
| 895 | 895 | *successful* invocation of :c:func:`Py_EnterRecursiveCall`. | |
| 896 | 896 | ||
| 897 | 897 | .. versionchanged:: 3.9 | |
| 898 | - This function is now also available in the limited API. | ||
| 898 | + This function is now also available in the :ref:`limited API <limited-c-api>`. | ||
| 899 | 899 | ||
| 900 | 900 | Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types requires | |
| 901 | 901 | special recursion handling. In addition to protecting the stack, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,9 +20,9 @@ but will need to be compiled separately for 3.9.x and 3.10.x. | |||
| 20 | 20 | ||
| 21 | 21 | There are two tiers of C API with different stability exepectations: | |
| 22 | 22 | ||
| 23 | - - *Unstable API*, may change in minor versions without a deprecation period. | ||
| 24 | - It is marked by the ``PyUnstable`` prefix in names. | ||
| 25 | - - *Limited API*, is compatible across several minor releases. | ||
| 23 | + - :ref:`Unstable API <unstable-c-api>`, may change in minor versions without | ||
| 24 | + a deprecation period. It is marked by the ``PyUnstable`` prefix in names. | ||
| 25 | + - :ref:`Limited API <limited-c-api>`, is compatible across several minor releases. | ||
| 26 | 26 | When :c:macro:`Py_LIMITED_API` is defined, only this subset is exposed | |
| 27 | 27 | from ``Python.h``. | |
| 28 | 28 | ||
@@ -55,19 +55,15 @@ CPython development and spend extra effort adjusting to changes. | |||
| 55 | 55 | Stable Application Binary Interface | |
| 56 | 56 | =================================== | |
| 57 | 57 | ||
| 58 | + .. _limited-c-api: | ||
| 59 | + | ||
| 60 | + Limited C API | ||
| 61 | + ------------- | ||
| 62 | + | ||
| 58 | 63 | Python 3.2 introduced the *Limited API*, a subset of Python's C API. | |
| 59 | 64 | Extensions that only use the Limited API can be | |
| 60 | 65 | compiled once and work with multiple versions of Python. | |
| 61 | - Contents of the Limited API are :ref:`listed below <stable-abi-list>`. | ||
| 62 | - | ||
| 63 | - To enable this, Python provides a *Stable ABI*: a set of symbols that will | ||
| 64 | - remain compatible across Python 3.x versions. The Stable ABI contains symbols | ||
| 65 | - exposed in the Limited API, but also other ones – for example, functions | ||
| 66 | - necessary to support older versions of the Limited API. | ||
| 67 | - | ||
| 68 | - (For simplicity, this document talks about *extensions*, but the Limited API | ||
| 69 | - and Stable ABI work the same way for all uses of the API – for example, | ||
| 70 | - embedding Python.) | ||
| 66 | + Contents of the Limited API are :ref:`listed below <limited-api-list>`. | ||
| 71 | 67 | ||
| 72 | 68 | .. c:macro:: Py_LIMITED_API | |
| 73 | 69 | ||
@@ -87,6 +83,23 @@ embedding Python.) | |||
| 87 | 83 | You can also define ``Py_LIMITED_API`` to ``3``. This works the same as | |
| 88 | 84 | ``0x03020000`` (Python 3.2, the version that introduced Limited API). | |
| 89 | 85 | ||
| 86 | + | ||
| 87 | + .. _stable-abi: | ||
| 88 | + | ||
| 89 | + Stable ABI | ||
| 90 | + ---------- | ||
| 91 | + | ||
| 92 | + To enable this, Python provides a *Stable ABI*: a set of symbols that will | ||
| 93 | + remain compatible across Python 3.x versions. | ||
| 94 | + | ||
| 95 | + The Stable ABI contains symbols exposed in the :ref:`Limited API | ||
| 96 | + <limited-c-api>`, but also other ones – for example, functions necessary to | ||
| 97 | + support older versions of the Limited API. | ||
| 98 | + | ||
| 99 | + (For simplicity, this document talks about *extensions*, but the Limited API | ||
| 100 | + and Stable ABI work the same way for all uses of the API – for example, | ||
| 101 | + embedding Python.) | ||
| 102 | + | ||
| 90 | 103 | On Windows, extensions that use the Stable ABI should be linked against | |
| 91 | 104 | ``python3.dll`` rather than a version-specific library such as | |
| 92 | 105 | ``python39.dll``. | |
@@ -131,9 +144,9 @@ Limited API Caveats | |||
| 131 | 144 | ------------------- | |
| 132 | 145 | ||
| 133 | 146 | Note that compiling with ``Py_LIMITED_API`` is *not* a complete guarantee that | |
| 134 | - code conforms to the Limited API or the Stable ABI. ``Py_LIMITED_API`` only | ||
| 135 | - covers definitions, but an API also includes other issues, such as expected | ||
| 136 | - semantics. | ||
| 147 | + code conforms to the :ref:`Limited API <limited-c-api>` or the :ref:`Stable ABI | ||
| 148 | + <stable-abi>`. ``Py_LIMITED_API`` only covers definitions, but an API also | ||
| 149 | + includes other issues, such as expected semantics. | ||
| 137 | 150 | ||
| 138 | 151 | One issue that ``Py_LIMITED_API`` does not guard against is calling a function | |
| 139 | 152 | with arguments that are invalid in a lower Python version. | |
@@ -166,9 +179,9 @@ Platform Considerations | |||
| 166 | 179 | ======================= | |
| 167 | 180 | ||
| 168 | 181 | ABI stability depends not only on Python, but also on the compiler used, | |
| 169 | - lower-level libraries and compiler options. For the purposes of the Stable ABI, | ||
| 170 | - these details define a “platform”. They usually depend on the OS | ||
| 171 | - type and processor architecture | ||
| 182 | + lower-level libraries and compiler options. For the purposes of | ||
| 183 | + the :ref:`Stable ABI <stable-abi>`, these details define a “platform”. They | ||
| 184 | + usually depend on the OS type and processor architecture | ||
| 172 | 185 | ||
| 173 | 186 | It is the responsibility of each particular distributor of Python | |
| 174 | 187 | to ensure that all Python versions on a particular platform are built | |
@@ -177,12 +190,12 @@ This is the case with Windows and macOS releases from ``python.org`` and many | |||
| 177 | 190 | third-party distributors. | |
| 178 | 191 | ||
| 179 | 192 | ||
| 180 | - .. _stable-abi-list: | ||
| 193 | + .. _limited-api-list: | ||
| 181 | 194 | ||
| 182 | 195 | Contents of Limited API | |
| 183 | 196 | ======================= | |
| 184 | 197 | ||
| 185 | 198 | ||
| 186 | - Currently, the Limited API includes the following items: | ||
| 199 | + Currently, the :ref:`Limited API <limited-c-api>` includes the following items: | ||
| 187 | 200 | ||
| 188 | 201 | .. limited-api-list:: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -288,7 +288,7 @@ There are these calling conventions: | |||
| 288 | 288 | ||
| 289 | 289 | .. versionchanged:: 3.10 | |
| 290 | 290 | ||
| 291 | - ``METH_FASTCALL`` is now part of the stable ABI. | ||
| 291 | + ``METH_FASTCALL`` is now part of the :ref:`stable ABI <stable-abi>`. | ||
| 292 | 292 | ||
| 293 | 293 | ||
| 294 | 294 | .. data:: METH_FASTCALL | METH_KEYWORDS | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,7 @@ Type Objects | |||
| 42 | 42 | Return the :c:member:`~PyTypeObject.tp_flags` member of *type*. This function is primarily | |
| 43 | 43 | meant for use with ``Py_LIMITED_API``; the individual flag bits are | |
| 44 | 44 | guaranteed to be stable across Python releases, but access to | |
| 45 | - :c:member:`~PyTypeObject.tp_flags` itself is not part of the limited API. | ||
| 45 | + :c:member:`~PyTypeObject.tp_flags` itself is not part of the :ref:`limited API <limited-c-api>`. | ||
| 46 | 46 | ||
| 47 | 47 | .. versionadded:: 3.2 | |
| 48 | 48 | ||
@@ -472,7 +472,7 @@ The following functions and structs are used to create | |||
| 472 | 472 | .. versionchanged:: 3.11 | |
| 473 | 473 | :c:member:`~PyBufferProcs.bf_getbuffer` and | |
| 474 | 474 | :c:member:`~PyBufferProcs.bf_releasebuffer` are now available | |
| 475 | - under the limited API. | ||
| 475 | + under the :ref:`limited API <limited-c-api>`. | ||
| 476 | 476 | ||
| 477 | 477 | .. c:member:: void *pfunc | |
| 478 | 478 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2150,7 +2150,7 @@ This results in types that are limited relative to types defined in Python: | |||
| 2150 | 2150 | include any subinterpreter-specific state. | |
| 2151 | 2151 | ||
| 2152 | 2152 | Also, since :c:type:`PyTypeObject` is only part of the :ref:`Limited API | |
| 2153 | - <stable>` as an opaque struct, any extension modules using static types must be | ||
| 2153 | + <limited-c-api>` as an opaque struct, any extension modules using static types must be | ||
| 2154 | 2154 | compiled for a specific Python minor version. | |
| 2155 | 2155 | ||
| 2156 | 2156 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -994,7 +994,7 @@ These are the UTF-8 codec APIs: | |||
| 994 | 994 | The return type is now ``const char *`` rather of ``char *``. | |
| 995 | 995 | ||
| 996 | 996 | .. versionchanged:: 3.10 | |
| 997 | - This function is a part of the :ref:`limited API <stable>`. | ||
| 997 | + This function is a part of the :ref:`limited API <limited-c-api>`. | ||
| 998 | 998 | ||
| 999 | 999 | ||
| 1000 | 1000 | .. c:function:: const char* PyUnicode_AsUTF8(PyObject *unicode) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -461,7 +461,7 @@ Module State Access from Slot Methods, Getters and Setters | |||
| 461 | 461 | ||
| 462 | 462 | .. After adding to limited API: | |
| 463 | 463 | ||
| 464 | - If you use the :ref:`limited API <stable>, | ||
| 464 | + If you use the :ref:`limited API <limited-c-api>`, | ||
| 465 | 465 | you must update ``Py_LIMITED_API`` to ``0x030b0000``, losing ABI | |
| 466 | 466 | compatibility with earlier versions. | |
| 467 | 467 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -803,7 +803,7 @@ The :mod:`test.support` module defines the following functions: | |||
| 803 | 803 | ||
| 804 | 804 | .. decorator:: requires_limited_api | |
| 805 | 805 | ||
| 806 | - Decorator for only running the test if :ref:`Limited C API <stable>` | ||
| 806 | + Decorator for only running the test if :ref:`Limited C API <limited-c-api>` | ||
| 807 | 807 | is available. | |
| 808 | 808 | ||
| 809 | 809 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2650,7 +2650,7 @@ Removed | |||
| 2650 | 2650 | * :c:func:`PyMarshal_WriteObjectToString` | |
| 2651 | 2651 | * the ``Py_MARSHAL_VERSION`` macro | |
| 2652 | 2652 | ||
| 2653 | - These are not part of the :ref:`limited API <stable-abi-list>`. | ||
| 2653 | + These are not part of the :ref:`limited API <limited-api-list>`. | ||
| 2654 | 2654 | ||
| 2655 | 2655 | (Contributed by Victor Stinner in :issue:`45474`.) | |
| 2656 | 2656 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1580,7 +1580,7 @@ New Features | |||
| 1580 | 1580 | ||
| 1581 | 1581 | (Contributed by Petr Viktorin in :gh:`103509`.) | |
| 1582 | 1582 | ||
| 1583 | - * Added the new limited C API function :c:func:`PyType_FromMetaclass`, | ||
| 1583 | + * Added the new :ref:`limited C API <limited-c-api>` function :c:func:`PyType_FromMetaclass`, | ||
| 1584 | 1584 | which generalizes the existing :c:func:`PyType_FromModuleAndSpec` using | |
| 1585 | 1585 | an additional metaclass argument. | |
| 1586 | 1586 | (Contributed by Wenzel Jakob in :gh:`93012`.) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments