> **Источник:** https://python-all.ru/3.14/c-api/index.html
>
> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.

---

# Справочное руководство по Python/C API

В данном руководстве описано API для программистов на C и C++, которые хотят создавать модули расширения или встраивать Python. Оно является дополнением к [Расширение и встраивание интерпретатора Python](https://python-all.ru/3.14/extending/index.html#extending-index), в котором описаны общие принципы написания расширений, но нет подробной документации по функциям API.

- [Введение](https://python-all.ru/3.14/c-api/intro.html)

  - [Совместимость версий языка](https://python-all.ru/3.14/c-api/intro.html#language-version-compatibility)
  - [Стандарты кодирования](https://python-all.ru/3.14/c-api/intro.html#coding-standards)
  - [Заголовочные файлы](https://python-all.ru/3.14/c-api/intro.html#include-files)
  - [Полезные макросы](https://python-all.ru/3.14/c-api/intro.html#useful-macros)
  - [Объекты, типы и счетчики ссылок](https://python-all.ru/3.14/c-api/intro.html#objects-types-and-reference-counts)
  - [Исключения](https://python-all.ru/3.14/c-api/intro.html#exceptions)
  - [Встраивание Python](https://python-all.ru/3.14/c-api/intro.html#embedding-python)
  - [Отладочные сборки](https://python-all.ru/3.14/c-api/intro.html#debugging-builds)
  - [Рекомендуемые сторонние инструменты](https://python-all.ru/3.14/c-api/intro.html#recommended-third-party-tools)
- [Стабильность C API](https://python-all.ru/3.14/c-api/stable.html)

  - [Нестабильное C API](https://python-all.ru/3.14/c-api/stable.html#unstable-c-api)
  - [Стабильный ABI](https://python-all.ru/3.14/c-api/stable.html#stable-application-binary-interface)
  - [Особенности платформ](https://python-all.ru/3.14/c-api/stable.html#platform-considerations)
  - [Содержимое ограниченного API](https://python-all.ru/3.14/c-api/stable.html#contents-of-limited-api)
- [Очень высокоуровневый слой](https://python-all.ru/3.14/c-api/veryhigh.html)

  - [Доступные стартовые символы](https://python-all.ru/3.14/c-api/veryhigh.html#available-start-symbols)
  - [Влияние на стек](https://python-all.ru/3.14/c-api/veryhigh.html#stack-effects)
- [Подсчёт ссылок](https://python-all.ru/3.14/c-api/refcounting.html)
- [Обработка исключений](https://python-all.ru/3.14/c-api/exceptions.html)

  - [Вывод и очистка](https://python-all.ru/3.14/c-api/exceptions.html#printing-and-clearing)
  - [Возбуждение исключений](https://python-all.ru/3.14/c-api/exceptions.html#raising-exceptions)
  - [Выдача предупреждений](https://python-all.ru/3.14/c-api/exceptions.html#issuing-warnings)
  - [Запрос индикатора ошибки](https://python-all.ru/3.14/c-api/exceptions.html#querying-the-error-indicator)
  - [Обработка сигналов](https://python-all.ru/3.14/c-api/exceptions.html#signal-handling)
  - [Классы исключений](https://python-all.ru/3.14/c-api/exceptions.html#exception-classes)
  - [Объекты исключений](https://python-all.ru/3.14/c-api/exceptions.html#exception-objects)
  - [Объекты исключений Unicode](https://python-all.ru/3.14/c-api/exceptions.html#unicode-exception-objects)
  - [Управление рекурсией](https://python-all.ru/3.14/c-api/exceptions.html#recursion-control)
  - [Типы исключений и предупреждений](https://python-all.ru/3.14/c-api/exceptions.html#exception-and-warning-types)
  - [Трассировки](https://python-all.ru/3.14/c-api/exceptions.html#tracebacks)
- [Определение модулей-расширений](https://python-all.ru/3.14/c-api/extension-modules.html)

  - [Несколько экземпляров модуля](https://python-all.ru/3.14/c-api/extension-modules.html#multiple-module-instances)
  - [Функция инициализации](https://python-all.ru/3.14/c-api/extension-modules.html#initialization-function)
  - [Многофазная инициализация](https://python-all.ru/3.14/c-api/extension-modules.html#multi-phase-initialization)
  - [Устаревшая однофазная инициализация](https://python-all.ru/3.14/c-api/extension-modules.html#legacy-single-phase-initialization)
- [Утилиты](https://python-all.ru/3.14/c-api/utilities.html)

  - [Утилиты операционной системы](https://python-all.ru/3.14/c-api/sys.html)
  - [Системные функции](https://python-all.ru/3.14/c-api/sys.html#system-functions)
  - [Управление процессами](https://python-all.ru/3.14/c-api/sys.html#process-control)
  - [Импорт модулей](https://python-all.ru/3.14/c-api/import.html)
  - [Поддержка маршалинга данных](https://python-all.ru/3.14/c-api/marshal.html)
  - [Разбор аргументов и сборка значений](https://python-all.ru/3.14/c-api/arg.html)
  - [Преобразование и форматирование строк](https://python-all.ru/3.14/c-api/conversion.html)
  - [Классификация и преобразование символов](https://python-all.ru/3.14/c-api/conversion.html#character-classification-and-conversion)
  - [PyHash API](https://python-all.ru/3.14/c-api/hash.html)
  - [Рефлексия](https://python-all.ru/3.14/c-api/reflection.html)
  - [Реестр кодировок и вспомогательные функции](https://python-all.ru/3.14/c-api/codec.html)
  - [PyTime C API](https://python-all.ru/3.14/c-api/time.html)
  - [Поддержка карт производительности](https://python-all.ru/3.14/c-api/perfmaps.html)
- [Слой абстрактных объектов](https://python-all.ru/3.14/c-api/abstract.html)

  - [Протокол объекта](https://python-all.ru/3.14/c-api/object.html)
  - [Протокол вызова](https://python-all.ru/3.14/c-api/call.html)
  - [Протокол чисел](https://python-all.ru/3.14/c-api/number.html)
  - [Протокол последовательностей](https://python-all.ru/3.14/c-api/sequence.html)
  - [Протокол отображений](https://python-all.ru/3.14/c-api/mapping.html)
  - [Протокол итератора](https://python-all.ru/3.14/c-api/iter.html)
  - [Протокол буфера](https://python-all.ru/3.14/c-api/buffer.html)
- [Слой конкретных объектов](https://python-all.ru/3.14/c-api/concrete.html)

  - [Базовые объекты](https://python-all.ru/3.14/c-api/concrete.html#fundamental-objects)
  - [Числовые объекты](https://python-all.ru/3.14/c-api/concrete.html#numeric-objects)
  - [Объекты последовательностей](https://python-all.ru/3.14/c-api/concrete.html#sequence-objects)
  - [Объекты контейнеров](https://python-all.ru/3.14/c-api/concrete.html#container-objects)
  - [Объекты функций](https://python-all.ru/3.14/c-api/concrete.html#function-objects)
  - [Прочие объекты](https://python-all.ru/3.14/c-api/concrete.html#other-objects)
  - [C API для модулей расширения](https://python-all.ru/3.14/c-api/concrete.html#c-api-for-extension-modules)
- [Инициализация и завершение интерпретатора](https://python-all.ru/3.14/c-api/interp-lifecycle.html)

  - [Перед инициализацией Python](https://python-all.ru/3.14/c-api/interp-lifecycle.html#before-python-initialization)
  - [Глобальные переменные конфигурации](https://python-all.ru/3.14/c-api/interp-lifecycle.html#global-configuration-variables)
  - [Инициализация и финализация интерпретатора](https://python-all.ru/3.14/c-api/interp-lifecycle.html#initializing-and-finalizing-the-interpreter)
  - [Предостережения относительно финализации во время выполнения](https://python-all.ru/3.14/c-api/interp-lifecycle.html#cautions-regarding-runtime-finalization)
  - [Параметры уровня процесса](https://python-all.ru/3.14/c-api/interp-lifecycle.html#process-wide-parameters)
- [Состояния потоков и глобальная блокировка интерпретатора](https://python-all.ru/3.14/c-api/threads.html)

  - [Отсоединение состояния потока от кода расширения](https://python-all.ru/3.14/c-api/threads.html#detaching-the-thread-state-from-extension-code)
  - [Потоки, созданные не в Python](https://python-all.ru/3.14/c-api/threads.html#non-python-created-threads)
  - [Устаревший API](https://python-all.ru/3.14/c-api/threads.html#legacy-api)
  - [Предостережения о fork()](https://python-all.ru/3.14/c-api/threads.html#cautions-about-fork)
  - [API высокого уровня](https://python-all.ru/3.14/c-api/threads.html#high-level-apis)
  - [API состояния GIL](https://python-all.ru/3.14/c-api/threads.html#gil-state-apis)
  - [API низкого уровня](https://python-all.ru/3.14/c-api/threads.html#low-level-apis)
- [Асинхронные уведомления](https://python-all.ru/3.14/c-api/threads.html#asynchronous-notifications)
- [API потоков операционной системы](https://python-all.ru/3.14/c-api/threads.html#operating-system-thread-apis)
- [Примитивы синхронизации](https://python-all.ru/3.14/c-api/synchronization.html)

  - [API критической секции Python](https://python-all.ru/3.14/c-api/synchronization.html#python-critical-section-api)
  - [Устаревшие API блокировок](https://python-all.ru/3.14/c-api/synchronization.html#legacy-locking-apis)
- [Поддержка локального хранилища потоков](https://python-all.ru/3.14/c-api/tls.html)

  - [API хранилища, специфичного для потоков](https://python-all.ru/3.14/c-api/tls.html#thread-specific-storage-api)
  - [Динамическое выделение памяти](https://python-all.ru/3.14/c-api/tls.html#dynamic-allocation)
  - [Методы](https://python-all.ru/3.14/c-api/tls.html#methods)
  - [Устаревшие API](https://python-all.ru/3.14/c-api/tls.html#legacy-apis)
- [Несколько интерпретаторов в процессе Python](https://python-all.ru/3.14/c-api/subinterpreters.html)

  - [GIL для каждого интерпретатора](https://python-all.ru/3.14/c-api/subinterpreters.html#a-per-interpreter-gil)
  - [Ошибки и предостережения](https://python-all.ru/3.14/c-api/subinterpreters.html#bugs-and-caveats)
  - [API высокого уровня](https://python-all.ru/3.14/c-api/subinterpreters.html#high-level-apis)
  - [API низкого уровня](https://python-all.ru/3.14/c-api/subinterpreters.html#low-level-apis)
  - [Расширенная поддержка отладчика](https://python-all.ru/3.14/c-api/subinterpreters.html#advanced-debugger-support)
- [Профилирование и трассировка](https://python-all.ru/3.14/c-api/profiling.html)
- [Трассировка ссылок](https://python-all.ru/3.14/c-api/profiling.html#reference-tracing)
- [Конфигурация инициализации Python](https://python-all.ru/3.14/c-api/init_config.html)

  - [PyInitConfig C API](https://python-all.ru/3.14/c-api/init_config.html#pyinitconfig-c-api)
  - [Параметры конфигурации](https://python-all.ru/3.14/c-api/init_config.html#configuration-options)
  - [API конфигурации времени выполнения Python](https://python-all.ru/3.14/c-api/init_config.html#runtime-python-configuration-api)
  - [PyConfig C API](https://python-all.ru/3.14/c-api/init_config.html#pyconfig-c-api)
  - [Py\_GetArgcArgv()](https://python-all.ru/3.14/c-api/init_config.html#py-getargcargv)
  - [Отложенное выполнение главного модуля](https://python-all.ru/3.14/c-api/init_config.html#delaying-main-module-execution)
- [Управление памятью](https://python-all.ru/3.14/c-api/memory.html)

  - [Обзор](https://python-all.ru/3.14/c-api/memory.html#overview)
  - [Домены аллокаторов](https://python-all.ru/3.14/c-api/memory.html#allocator-domains)
  - [Интерфейс низкоуровневой памяти](https://python-all.ru/3.14/c-api/memory.html#raw-memory-interface)
  - [Интерфейс памяти](https://python-all.ru/3.14/c-api/memory.html#memory-interface)
  - [Аллокаторы объектов](https://python-all.ru/3.14/c-api/memory.html#object-allocators)
  - [Аллокаторы памяти по умолчанию](https://python-all.ru/3.14/c-api/memory.html#default-memory-allocators)
  - [Настройка аллокаторов памяти](https://python-all.ru/3.14/c-api/memory.html#customize-memory-allocators)
  - [Отладочные перехватчики аллокаторов памяти Python](https://python-all.ru/3.14/c-api/memory.html#debug-hooks-on-the-python-memory-allocators)
  - [Аллокатор pymalloc](https://python-all.ru/3.14/c-api/memory.html#the-pymalloc-allocator)
  - [Аллокатор mimalloc](https://python-all.ru/3.14/c-api/memory.html#the-mimalloc-allocator)
  - [C API модуля tracemalloc](https://python-all.ru/3.14/c-api/memory.html#tracemalloc-c-api)
  - [Примеры](https://python-all.ru/3.14/c-api/memory.html#examples)
- [Поддержка реализации объектов](https://python-all.ru/3.14/c-api/objimpl.html)

  - [Выделение объектов в куче](https://python-all.ru/3.14/c-api/allocation.html)
  - [Жизненный цикл объекта](https://python-all.ru/3.14/c-api/lifecycle.html)
  - [Общие структуры объектов](https://python-all.ru/3.14/c-api/structures.html)
  - [Структуры объектов типов](https://python-all.ru/3.14/c-api/typeobj.html)
  - [Поддержка циклической сборки мусора](https://python-all.ru/3.14/c-api/gcsupport.html)
- [Версионирование API и ABI](https://python-all.ru/3.14/c-api/apiabiversion.html)

  - [Константы версии времени сборки](https://python-all.ru/3.14/c-api/apiabiversion.html#build-time-version-constants)
  - [Версия времени выполнения](https://python-all.ru/3.14/c-api/apiabiversion.html#run-time-version)
  - [Макросы упаковки битов](https://python-all.ru/3.14/c-api/apiabiversion.html#bit-packing-macros)
- [Мониторинг C API](https://python-all.ru/3.14/c-api/monitoring.html)
- [Генерация событий выполнения](https://python-all.ru/3.14/c-api/monitoring.html#generating-execution-events)

  - [Управление состоянием мониторинга](https://python-all.ru/3.14/c-api/monitoring.html#managing-the-monitoring-state)
