mirror of https://github.com/python/cpython
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
5 years ago | |
|---|---|---|
| .. | ||
| cpython | 5 years ago | |
| internal | 5 years ago | |
| Python.h | 5 years ago | |
| README.rst | 5 years ago | |
| abstract.h | 5 years ago | |
| bltinmodule.h | 17 years ago | |
| boolobject.h | 5 years ago | |
| bytearrayobject.h | 6 years ago | |
| bytesobject.h | 5 years ago | |
| cellobject.h | 5 years ago | |
| ceval.h | 5 years ago | |
| classobject.h | 6 years ago | |
| code.h | 6 years ago | |
| codecs.h | 5 years ago | |
| compile.h | 5 years ago | |
| complexobject.h | 6 years ago | |
| context.h | 6 years ago | |
| datetime.h | 5 years ago | |
| descrobject.h | 5 years ago | |
| dictobject.h | 5 years ago | |
| dynamic_annotations.h | 14 years ago | |
| enumobject.h | 22 years ago | |
| errcode.h | 5 years ago | |
| eval.h | 5 years ago | |
| exports.h | 6 years ago | |
| fileobject.h | 5 years ago | |
| fileutils.h | 6 years ago | |
| floatobject.h | 6 years ago | |
| frameobject.h | 6 years ago | |
| funcobject.h | 5 years ago | |
| genericaliasobject.h | 6 years ago | |
| genobject.h | 5 years ago | |
| import.h | 6 years ago | |
| interpreteridobject.h | 7 years ago | |
| intrcheck.h | 5 years ago | |
| iterobject.h | 5 years ago | |
| listobject.h | 6 years ago | |
| longintrepr.h | 8 years ago | |
| longobject.h | 5 years ago | |
| marshal.h | 14 years ago | |
| memoryobject.h | 6 years ago | |
| methodobject.h | 5 years ago | |
| modsupport.h | 5 years ago | |
| moduleobject.h | 5 years ago | |
| namespaceobject.h | 9 years ago | |
| object.h | 5 years ago | |
| objimpl.h | 5 years ago | |
| opcode.h | 5 years ago | |
| osdefs.h | 7 years ago | |
| osmodule.h | 9 years ago | |
| patchlevel.h | 5 years ago | |
| py_curses.h | 6 years ago | |
| pycapsule.h | 6 years ago | |
| pydtrace.d | 7 years ago | |
| pydtrace.h | 7 years ago | |
| pyerrors.h | 5 years ago | |
| pyexpat.h | 7 years ago | |
| pyframe.h | 6 years ago | |
| pyhash.h | 6 years ago | |
| pylifecycle.h | 5 years ago | |
| pymacconfig.h | 9 years ago | |
| pymacro.h | 5 years ago | |
| pymath.h | 7 years ago | |
| pymem.h | 5 years ago | |
| pyport.h | 5 years ago | |
| pystate.h | 6 years ago | |
| pystrcmp.h | 18 years ago | |
| pystrhex.h | 7 years ago | |
| pystrtod.h | 9 years ago | |
| pythonrun.h | 5 years ago | |
| pythread.h | 6 years ago | |
| rangeobject.h | 6 years ago | |
| setobject.h | 5 years ago | |
| sliceobject.h | 6 years ago | |
| structmember.h | 9 years ago | |
| structseq.h | 6 years ago | |
| sysmodule.h | 7 years ago | |
| token.h | 5 years ago | |
| traceback.h | 6 years ago | |
| tracemalloc.h | 7 years ago | |
| tupleobject.h | 6 years ago | |
| typeslots.h | 5 years ago | |
| unicodeobject.h | 5 years ago | |
| warnings.h | 8 years ago | |
| weakrefobject.h | 6 years ago | |
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.