Skip to content

Commit d3bcfc2

Browse files
committed
Add PyInterface_Get and fix lint errors
1 parent 1a56de3 commit d3bcfc2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

peps/pep-0809.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ releases that support the ABI.
159159

160160
Accidental changes that occur in releases should be reverted as soon as
161161
discovered, ideally without breaking regular compatibility rules. However, it is
162-
better to have `3.x.1` fix a Stable ABI issue introduced in `3.x.0` rather than
163-
to leave it present until `3.y.0`.
162+
better to have ``3.x.1`` fix a Stable ABI issue introduced in ``3.x.0`` rather
163+
than to leave it present until ``3.y.0``.
164164

165165
Historically, we have used clever C preprocessor constructs to try and preserve
166166
both source and binary-level compatibility, for example, by selecting macro or
@@ -264,13 +264,25 @@ same operation, but less efficiently. The final result of this example is a
264264
single extension module that is binary compatible with *all* releases supporting
265265
``abi2026`` but is more efficient when running against newer releases of Python.
266266

267+
Additionally, ``PyInterface_Get(void *intf)`` will return a global struct, for
268+
APIs that are not specific to a particular object. It is intended that the two
269+
"get" APIs will support different interfaces, even though they share the
270+
namespace. APIs provided through the struct for a global interface will almost
271+
always require a runtime or interpreter parameter, which is unnecessary when an
272+
object is available. Further, ``PyInterface_Get`` will not require a Python
273+
thread to be attached (a.k.a. the GIL is not required), though any functions
274+
provided by an interface may require it.
275+
267276
Overview complete, here is the full specification of each new API:
268277

269278
.. code-block:: c
270279
271280
// Abstract API to request an interface for an object (or type).
272281
PyAPI_FUNC(int) PyObject_GetInterface(PyObject *obj, void *intf);
273282
283+
// API to request a global interface
284+
PyAPI_FUNC(int) PyInterface_Get(void *intf);
285+
274286
// API to release an interface.
275287
PyAPI_FUNC(int) PyInterface_Release(void *intf);
276288

0 commit comments

Comments
 (0)