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.
 
 
 
 
 
 
Pablo Galindo b280248be8
bpo-43822: Improve syntax errors for missing commas (GH-25377)
5 years ago
..
cpython bpo-38530: Offer suggestions on NameError (GH-25397) 5 years ago
internal bpo-38530: Offer suggestions on AttributeError (#16856) 5 years ago
Python.h bpo-43244: Remove the pyarena.h header (GH-25007) 5 years ago
README.rst bpo-43416: Add Include/README.rst (GH-24884) 5 years ago
abstract.h bpo-31861: Add aiter and anext to builtins (#23847) 5 years ago
bltinmodule.h these builtins have to be initialized 17 years ago
boolobject.h bpo-43753: Add Py_Is() and Py_IsNone() functions (GH-25227) 5 years ago
bytearrayobject.h bpo-39573: Add Py_IS_TYPE() function (GH-18488) 6 years ago
bytesobject.h bpo-42431: Fix outdated bytes comments (GH-23458) 5 years ago
cellobject.h bpo-30459: Cast the result of PyCell_SET to void (GH-23654) 5 years ago
ceval.h bpo-41936. Remove macros Py_ALLOW_RECURSION/Py_END_ALLOW_RECURSION (GH-22552) 5 years ago
classobject.h bpo-39573: PyXXX_Check() macros use Py_IS_TYPE() (GH-18508) 6 years ago
code.h bpo-40421: Add Include/cpython/code.h header file (GH-19756) 6 years ago
codecs.h bpo-41842: Add codecs.unregister() function (GH-22360) 5 years ago
compile.h bpo-35134: Add include/cpython/compile.h (GH-24922) 5 years ago
complexobject.h bpo-39573: Add Py_IS_TYPE() function (GH-18488) 6 years ago
context.h bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769) 6 years ago
datetime.h bpo-30155: Add macros to get tzinfo from datetime instances (GH-21633) 5 years ago
descrobject.h bpo-40170: Convert PyDescr_IsData() to static inline function (GH-24535) 5 years ago
dictobject.h bpo-41845: Move PyObject_GenericGetDict() back into the limited API (GH22646) 5 years ago
dynamic_annotations.h Issue #25314: store_true and store_false also create appropriate defaults. 14 years ago
enumobject.h Implement and apply PEP 322, reverse iteration 22 years ago
errcode.h bpo-40176: Improve error messages for unclosed string literals (GH-19346) 5 years ago
eval.h bpo-42990: Further refactoring of PyEval_ functions. (GH-24368) 5 years ago
exports.h bpo-11410: Standardize and use symbol visibility attributes across POSIX and Windows. (GH-16347) 6 years ago
fileobject.h bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited API (GH-22621) 5 years ago
fileutils.h bpo-35134: Add Include/cpython/fileutils.h header file (GH-18493) 6 years ago
floatobject.h bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769) 6 years ago
frameobject.h bpo-40421: Add pyframe.h header file (GH-19755) 6 years ago
funcobject.h bpo-42990: Introduce 'frame constructor' struct to simplify API for PyEval_CodeEval and friends (GH-24298) 5 years ago
genericaliasobject.h bpo-39481: Implementation for PEP 585 (#18239) 6 years ago
genobject.h Delete PyGen_Send (#22663) 5 years ago
import.h bpo-39372: Clean header files of declared interfaces with no implementations (GH-18037) 6 years ago
interpreteridobject.h bpo-36097: Use only public C-API in the_xxsubinterpreters module (adding as necessary). (#12003) 7 years ago
intrcheck.h bpo-41713: Remove PyOS_InitInterrupts() function (GH-23342) 5 years ago
iterobject.h bpo-43770: _PyTypes_Init() inits _PyAnextAwaitable_Type (GH-25266) 5 years ago
listobject.h bpo-39573: Add Py_IS_TYPE() function (GH-18488) 6 years ago
longintrepr.h bpo-32150: Expand tabs to spaces in C files. (#4583) 8 years ago
longobject.h bpo-42161: Remove private _PyLong_Zero and _PyLong_One (GH-23003) 5 years ago
marshal.h Issue #25314: store_true and store_false also create appropriate defaults. 14 years ago
memoryobject.h bpo-39573: Add Py_IS_TYPE() function (GH-18488) 6 years ago
methodobject.h bpo-43688: Fix Py_LIMITED_API version of xxlimited (GH-25135) 5 years ago
modsupport.h bpo-1635741: Add PyModule_AddObjectRef() function (GH-23122) 5 years ago
moduleobject.h bpo-42923: Dump extension modules on fatal error (GH-24207) 5 years ago
namespaceobject.h Issue #26900: Excluded underscored names and other private API from limited API. 9 years ago
object.h bpo-43753: Add Py_Is() and Py_IsNone() functions (GH-25227) 5 years ago
objimpl.h bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587) 5 years ago
opcode.h bpo-43683: Handle generator entry in bytecode (GH-25138) 5 years ago
osdefs.h bpo-31904: Add cross-build support for VxWorks RTOS (GH-11968) 7 years ago
osmodule.h Issue #29058: All stable API extensions added after Python 3.2 are now 9 years ago
patchlevel.h Post 3.10.0a7 5 years ago
py_curses.h bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601) 6 years ago
pycapsule.h bpo-39573: Add Py_IS_TYPE() function (GH-18488) 6 years ago
pydtrace.d bpo-36842: Implement PEP 578 (GH-12613) 7 years ago
pydtrace.h bpo-36842: Implement PEP 578 (GH-12613) 7 years ago
pyerrors.h bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481) 5 years ago
pyexpat.h bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146) 7 years ago
pyframe.h bpo-40421: Add PyFrame_GetCode() function (GH-19757) 6 years ago
pyhash.h bpo-40602: Add _Py_HashPointerRaw() function (GH-20056) 6 years ago
pylifecycle.h bpo-42591: Export missing Py_FrozenMain() symbol (GH-23730) 5 years ago
pymacconfig.h Minor spelling fixes 9 years ago
pymacro.h bpo-41875: Use __builtin_unreachable when possible (GH-22433) 5 years ago
pymath.h Fix typos in comments, docs and test names (#15018) 7 years ago
pymem.h bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587) 5 years ago
pyport.h bpo-43271: Re-enable ceval.c optimizations for Windows debug builds (GH-24739) 5 years ago
pystate.h Update code comment re: location of struct _is. (GH-20067) 6 years ago
pystrcmp.h Applied patch #1635: Float patch for inf and nan on Windows (and other platforms). 18 years ago
pystrhex.h bpo-22385: Support output separators in hex methods. (#13578) 7 years ago
pystrtod.h Issue #26331: Implement the parsing part of PEP 515. 9 years ago
pythonrun.h bpo-43244: Remove symtable.h header file (GH-24910) 5 years ago
pythread.h bpo-40089: Add _at_fork_reinit() method to locks (GH-19195) 6 years ago
rangeobject.h bpo-39573: Add Py_IS_TYPE() function (GH-18488) 6 years ago
setobject.h bpo-43277: Add PySet_CheckExact to the C-API (GH-24598) 5 years ago
sliceobject.h bpo-39573: Add Py_IS_TYPE() function (GH-18488) 6 years ago
structmember.h Issue #28761: The fields name and doc of structures PyMemberDef, PyGetSetDef, 9 years ago
structseq.h bpo-38650: Constify PyStructSequence_UnnamedField. (GH-17005) 6 years ago
sysmodule.h bpo-36842: Implement PEP 578 (GH-12613) 7 years ago
token.h bpo-43822: Improve syntax errors for missing commas (GH-25377) 5 years ago
traceback.h bpo-40421: Add pyframe.h header file (GH-19755) 6 years ago
tracemalloc.h bpo-35053: Define _PyTraceMalloc_NewReference in object.h (GH-10107) 7 years ago
tupleobject.h bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769) 6 years ago
typeslots.h bpo-42085: Introduce dedicated entry in PyAsyncMethods for sending values (#22780) 5 years ago
unicodeobject.h bpo-41784: make PyUnicode_AsUTF8AndSize part of the limited API (GH-22252) 5 years ago
warnings.h bpo-32591: Add native coroutine origin tracking (#5250) 8 years ago
weakrefobject.h bpo-39573: Add Py_IS_TYPE() function (GH-18488) 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.