Skip to content

Document the entire C API #141004

@ZeroIntensity

Description

@ZeroIntensity

@encukou has done great work getting us to document newly added C API in recent versions (#135755, #118915), but unfortunately, we still have plenty of undocumented APIs. I'd like to begin working towards a future where the C API documentation is extensive, up-to-date, and most importantly, helpful to users.

Here's my plan:

  1. Document all remaining C APIs (macros, static inline functions, and exported symbols) that are prefixed with Py.
  2. Add a CI job that prevents new C APIs from being added to public headers without documentation.
  3. Improve our "Extending and Embedding" tutorial. I started on this a little while ago, but I think it would be better to get the full C API documented before we do that.

I'm going to work on this myself, but others are welcome to send PRs where necessary. I've applied the easy label to this for any newcomers who are interested in helping.

Below is a list of CPython's undocumented C API. I'm sure many of these aren't documented intentionally, so we should either deprecate them or keep a canonical list of "public but undocumented" somewhere.


bltinmodule.h

enumobject.h

bytearrayobject.h

bytesobject.h

codecs.h

compile.h

datetime.h

  • PyDateTime_CAPSULE_NAME

descrobject.h

  • PyClassMethodDescr_Type
  • PyDictProxy_Type
  • PyGetSetDescr_Type
  • PyMemberDescr_Type
  • PyMethodDescr_Type
  • PyWrapperDescr_Type

dictobject.h

fileobject.h

listobject.h

memoryobject.h

objimpl.h

(All covered by #141146)

  • PyObject_DEL
  • PyObject_FREE
  • PyObject_INIT_VAR
  • PyObject_INIT
  • PyObject_MALLOC
  • PyObject_NEW_VAR
  • PyObject_NEW
  • PyObject_REALLOC

pybuffer.h

pycapsule.h

pydtrace.h

  • PyDTrace_AUDIT_ENABLED
  • PyDTrace_AUDIT
  • PyDTrace_FUNCTION_ENTRY_ENABLED
  • PyDTrace_FUNCTION_ENTRY
  • PyDTrace_FUNCTION_RETURN_ENABLED
  • PyDTrace_FUNCTION_RETURN
  • PyDTrace_GC_DONE_ENABLED
  • PyDTrace_GC_DONE
  • PyDTrace_GC_START_ENABLED
  • PyDTrace_GC_START
  • PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED
  • PyDTrace_IMPORT_FIND_LOAD_DONE
  • PyDTrace_IMPORT_FIND_LOAD_START_ENABLED
  • PyDTrace_IMPORT_FIND_LOAD_START
  • PyDTrace_INSTANCE_DELETE_DONE_ENABLED
  • PyDTrace_INSTANCE_DELETE_DONE
  • PyDTrace_INSTANCE_DELETE_START_ENABLED
  • PyDTrace_INSTANCE_DELETE_START
  • PyDTrace_INSTANCE_NEW_DONE_ENABLED
  • PyDTrace_INSTANCE_NEW_DONE
  • PyDTrace_INSTANCE_NEW_START_ENABLED
  • PyDTrace_INSTANCE_NEW_START
  • PyDTrace_LINE_ENABLED
  • PyDTrace_LINE

pyerrors.h

pyhash.h

(covered in #141205 and #141233)

pystrtod.h

rangeobject.h

setobject.h

traceback.h

tupleobject.h

exports.h

floatobject.h

longobject.h

methodobject.h

modsupport.h

  • PyABIInfo_FREETHREADING_AGNOSTIC

moduleobject.h

py_curses.h

(covered by #141254)

  • PyCursesInitialisedColor
  • PyCursesInitialised
  • PyCursesSetupTermCalled
  • PyCursesWindow_Check
  • PyCursesWindow_Type
  • PyCurses_API_pointers
  • PyCurses_CAPSULE_NAME

pymacro.h

pymath.h

typeslots.h

(Covered in #138190)

unicodeobject.h

object.h

pyexpat.h

(covered in #141259)

  • PyExpat_CAPI_MAGIC
  • PyExpat_CAPSULE_NAME

pyport.h

  • Py_ALIGNED
  • Py_ARITHMETIC_RIGHT_SHIFT
  • Py_CAN_START_THREADS
  • Py_FORCE_EXPANSION
  • Py_GCC_ATTRIBUTE
  • Py_LL
  • Py_LOCAL_INLINE
  • Py_LOCAL
  • Py_MEMCPY
  • Py_SAFE_DOWNCAST
  • Py_ULL
  • Py_VA_COPY

weakrefobject.h

cpython/pyctype.h

cpython/compile.h

  • PyCF_ALLOW_INCOMPLETE_INPUT
  • PyCF_COMPILE_MASK
  • PyCF_DONT_IMPLY_DEDENT
  • PyCF_IGNORE_COOKIE
  • PyCF_MASK_OBSOLETE
  • PyCF_MASK
  • PyCF_SOURCE_IS_UTF8
  • PyCompile_OpcodeStackEffectWithJump
  • PyCompile_OpcodeStackEffect

cpython/descrobject.h

  • PyDescr_COMMON
  • PyDescr_NAME
  • PyDescr_TYPE
  • PyWrapperFlag_KEYWORDS

cpython/fileobject.h

  • PyFile_NewStdPrinter
  • PyFile_OpenCodeObject
  • PyFile_OpenCode
  • PyStdPrinter_Type
  • Py_UniversalNewlineFgets

cpython/methodobject.h

cpython/odictobject.h

(All covered by #141136)

  • PyODictItems_Type
  • PyODictIter_Type
  • PyODictKeys_Type
  • PyODictValues_Type
  • PyODict_CheckExact
  • PyODict_Check
  • PyODict_Contains
  • PyODict_DelItem
  • PyODict_GetItemString
  • PyODict_GetItemWithError
  • PyODict_GetItem
  • PyODict_New
  • PyODict_SIZE
  • PyODict_SetItem
  • PyODict_Size
  • PyODict_Type

cpython/picklebufobject.h

  • PyPickleBuffer_Check
  • PyPickleBuffer_FromObject
  • PyPickleBuffer_GetBuffer
  • PyPickleBuffer_Release
  • PyPickleBuffer_Type

cpython/setobject.h

  • PySet_MINSIZE

cpython/dictobject.h

cpython/genobject.h

  • PyAsyncGenASend_CheckExact
  • PyAsyncGen_CheckExact
  • PyAsyncGen_New
  • PyAsyncGen_Type
  • PyGen_GetCode

cpython/import.h

  • PyImport_Inittab

cpython/longintrepr.h

  • PyLong_BASE
  • PyLong_MASK
  • PyLong_SHIFT

cpython/pyerrors.h

cpython/pyframe.h

  • PyUnstable_EXECUTABLE_KINDS
  • PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION
  • PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR
  • PyUnstable_EXECUTABLE_KIND_PY_FUNCTION
  • PyUnstable_EXECUTABLE_KIND_SKIP

cpython/funcobject.h

cpython/unicodeobject.h

pystrcmp.h

  • PyOS_mystricmp
  • PyOS_mystrnicmp

intrcheck.h

  • PyOS_InterruptOccurred

ceval.h

pythread.h

  • PyThread_GetInfo
  • PyThread_acquire_lock_timed
  • PyThread_acquire_lock
  • PyThread_allocate_lock
  • PyThread_free_lock
  • PyThread_get_stacksize
  • PyThread_get_thread_ident
  • PyThread_get_thread_native_id
  • PyThread_init_thread
  • PyThread_release_lock
  • PyThread_set_stacksize
  • PyThread_start_new_thread

cpython/frameobject.h

cpython/objimpl.h

  • PyType_SUPPORTS_WEAKREFS

cpython/pythonrun.h

  • PyRun_InteractiveOneObject

cpython/ceval.h

  • PyUnstable_CopyPerfMapFile
  • PyUnstable_PerfTrampoline_CompileCode
  • PyUnstable_PerfTrampoline_SetPersistAfterFork

cpython/pylifecycle.h

  • Py_FrozenMain

cpython/warnings.h

cpython/code.h

  • PyCode_Optimize

cpython/object.h

  • PyType_Unwatch

Linked PRs

Metadata

Metadata

Assignees

Labels

3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesdocsDocumentation in the Doc dirtopic-C-API

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions