cpython/Include
Steve Dower 87655e2cf5
bpo-42800: Rename AUDIT_READ to PY_AUDIT_READ (GH-25736)
2021-04-30 01:08:55 +01:00
..
cpython bpo-42739: Don't use sentinels to mark end of line table. (GH-25657) 2021-04-29 13:12:51 +01:00
internal bpo-43892: Make match patterns explicit in the AST (GH-25585) 2021-04-28 22:58:44 -07:00
Python.h bpo-43774: Remove unused PYMALLOC_DEBUG macro (GH-25711) 2021-04-29 10:47:47 +02:00
README.rst bpo-43416: Add Include/README.rst (GH-24884) 2021-03-25 17:16:31 +01:00
abstract.h bpo-31861: Add aiter and anext to builtins (#23847) 2021-03-23 15:47:21 -07:00
bltinmodule.h
boolobject.h bpo-43795: PEP-652: Simplify headers for easier static analysis (GH-25483) 2021-04-23 14:14:00 +02:00
bytearrayobject.h
bytesobject.h bpo-42431: Fix outdated bytes comments (GH-23458) 2020-12-03 12:46:16 +02:00
cellobject.h bpo-30459: Cast the result of PyCell_SET to void (GH-23654) 2020-12-07 11:56:20 +01:00
ceval.h
classobject.h
code.h
codecs.h
compile.h bpo-35134: Add include/cpython/compile.h (GH-24922) 2021-03-22 09:32:11 +01:00
complexobject.h
context.h
datetime.h
descrobject.h bpo-40170: Convert PyDescr_IsData() to static inline function (GH-24535) 2021-02-16 08:50:00 +01:00
dictobject.h
dynamic_annotations.h
enumobject.h
errcode.h bpo-40176: Improve error messages for unclosed string literals (GH-19346) 2021-01-20 13:38:47 -08:00
eval.h bpo-42990: Further refactoring of PyEval_ functions. (GH-24368) 2021-02-01 10:42:03 +00:00
exports.h
fileobject.h
fileutils.h bpo-43795: PEP-652: Clean up the stable ABI/limited API (GH-25482) 2021-04-23 14:17:58 +02:00
floatobject.h
frameobject.h
funcobject.h bpo-42990: Introduce 'frame constructor' struct to simplify API for PyEval_CodeEval and friends (GH-24298) 2021-01-29 13:24:55 +00:00
genericaliasobject.h
genobject.h
import.h
interpreteridobject.h
intrcheck.h bpo-41713: Remove PyOS_InitInterrupts() function (GH-23342) 2020-11-17 16:22:23 +01:00
iterobject.h bpo-43770: _PyTypes_Init() inits _PyAnextAwaitable_Type (GH-25266) 2021-04-08 09:58:15 +02:00
listobject.h
longintrepr.h
longobject.h bpo-42161: Remove private _PyLong_Zero and _PyLong_One (GH-23003) 2020-10-27 21:34:33 +01:00
marshal.h
memoryobject.h
methodobject.h bpo-43688: Fix Py_LIMITED_API version of xxlimited (GH-25135) 2021-04-01 15:09:33 +02:00
modsupport.h bpo-1635741: Add PyModule_AddObjectRef() function (GH-23122) 2020-11-04 13:59:15 +01:00
moduleobject.h bpo-42923: Dump extension modules on fatal error (GH-24207) 2021-01-18 20:47:13 +01:00
namespaceobject.h
object.h bpo-43908: Add Py_TPFLAGS_IMMUTABLETYPE flag (GH-25520) 2021-04-28 19:02:42 +02:00
objimpl.h bpo-43774: Remove unused PYMALLOC_DEBUG macro (GH-25711) 2021-04-29 10:47:47 +02:00
opcode.h bpo-43683: Handle generator entry in bytecode (GH-25138) 2021-04-06 11:48:59 +01:00
osdefs.h
osmodule.h
patchlevel.h Post 3.10.0a7 2021-04-05 18:04:54 +01:00
py_curses.h
pycapsule.h
pydtrace.d
pydtrace.h
pyerrors.h bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481) 2021-03-29 12:28:14 +09:00
pyexpat.h
pyframe.h
pyhash.h bpo-43795: PEP-652: Clean up the stable ABI/limited API (GH-25482) 2021-04-23 14:17:58 +02:00
pylifecycle.h bpo-42591: Export missing Py_FrozenMain() symbol (GH-23730) 2020-12-10 18:39:17 +01:00
pymacconfig.h
pymacro.h
pymath.h
pymem.h bpo-43774: Remove unused PYMALLOC_DEBUG macro (GH-25711) 2021-04-29 10:47:47 +02:00
pyport.h bpo-43795: PEP-652: Simplify headers for easier static analysis (GH-25483) 2021-04-23 14:14:00 +02:00
pystate.h
pystrcmp.h
pystrhex.h
pystrtod.h
pythonrun.h bpo-43868: Remove PyOS_ReadlineFunctionPointer from the stable ABI list (GH-25442) 2021-04-23 14:23:38 +02:00
pythread.h
rangeobject.h
setobject.h bpo-43277: Add PySet_CheckExact to the C-API (GH-24598) 2021-02-20 18:03:08 +00:00
sliceobject.h
structmember.h bpo-42800: Rename AUDIT_READ to PY_AUDIT_READ (GH-25736) 2021-04-30 01:08:55 +01:00
structseq.h
sysmodule.h
token.h bpo-43822: Improve syntax errors for missing commas (GH-25377) 2021-04-15 21:38:45 +01:00
traceback.h
tracemalloc.h
tupleobject.h
typeslots.h bpo-42085: Introduce dedicated entry in PyAsyncMethods for sending values (#22780) 2020-11-10 12:09:55 -08:00
unicodeobject.h
warnings.h
weakrefobject.h

README.rst

The Python C API
================

The C API is divided into three sections:

1. ``Include/``
2. ``Include/cpython/``
3. ``Include/internal/``


Include: Limited API
====================

``Include/``, excluding the ``cpython`` and ``internal`` subdirectories,
contains the public Limited API (Application Programming Interface).
The Limited API is a subset of the C API, designed to guarantee ABI
stability across Python 3 versions, and is defined in :pep:`384`.

Guidelines for expanding the Limited API:

- Functions *must not* steal references
- Functions *must not* return borrowed references
- Functions returning references *must* return a strong reference
- Macros should not expose implementation details
- Please start a public discussion before expanding the API
- Functions or macros with a ``_Py`` prefix do not belong in ``Include/``.

It is possible to add a function or macro to the Limited API from a
given Python version.  For example, to add a function to the Limited API
from Python 3.10 and onwards, wrap it with
``#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000``.


Include/cpython: CPython implementation details
===============================================

``Include/cpython/`` contains the public API that is excluded from the
Limited API and the Stable ABI.

Guidelines for expanding the public API:

- Functions *must not* steal references
- Functions *must not* return borrowed references
- Functions returning references *must* return a strong reference


Include/internal: The internal API
==================================


With PyAPI_FUNC or PyAPI_DATA
-----------------------------

Functions or structures in ``Include/internal/`` defined with
``PyAPI_FUNC`` or ``PyAPI_DATA`` are internal functions which are
exposed only for specific use cases like debuggers and profilers.


With the extern keyword
-----------------------

Functions in ``Include/internal/`` defined with the ``extern`` keyword
*must not and can not* be used outside the CPython code base.  Only
built-in stdlib extensions (built with the ``Py_BUILD_CORE_BUILTIN``
macro defined) can use such functions.

When in doubt, new internal C functions should be defined in
``Include/internal`` using the ``extern`` keyword.