Документация Python неофициальный перевод

debug.md

159 строк · 16.3 КБ · обычная страница · сырой текст · скачать

1> **Источник:** https://python-all.ru/3.16/library/debug.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# Отладка и профилирование89Эти библиотеки помогают в разработке на Python: отладчик позволяет пошагово выполнять код, анализировать стековые кадры и устанавливать точки останова и т.д., а профилировщики запускают код и предоставляют детальную разбивку времени выполнения, что позволяет выявить узкие места в программах. События аудита обеспечивают прозрачность поведения во время выполнения, которое в противном случае потребовало бы интрузивной отладки или внесения исправлений.1011- [Таблица событий аудита](https://python-all.ru/3.16/library/audit_events.html)12- [`bdb` – фреймворк отладчика](https://python-all.ru/3.16/library/bdb.html)13- [`faulthandler` – дамп трассировки Python](https://python-all.ru/3.16/library/faulthandler.html)1415  - [Дамп трассировки](https://python-all.ru/3.16/library/faulthandler.html#dumping-the-traceback)16  - [Дамп стека C](https://python-all.ru/3.16/library/faulthandler.html#dumping-the-c-stack)1718    - [Совместимость стека C](https://python-all.ru/3.16/library/faulthandler.html#c-stack-compatibility)19  - [Состояние обработчика сбоев](https://python-all.ru/3.16/library/faulthandler.html#fault-handler-state)20  - [Дамп трассировок по тайм-ауту](https://python-all.ru/3.16/library/faulthandler.html#dumping-the-tracebacks-after-a-timeout)21  - [Дамп трассировки по сигналу пользователя](https://python-all.ru/3.16/library/faulthandler.html#dumping-the-traceback-on-a-user-signal)22  - [Проблема с файловыми дескрипторами](https://python-all.ru/3.16/library/faulthandler.html#issue-with-file-descriptors)23  - [Пример](https://python-all.ru/3.16/library/faulthandler.html#example)24- [`pdb` – отладчик Python](https://python-all.ru/3.16/library/pdb.html)2526  - [Интерфейс командной строки](https://python-all.ru/3.16/library/pdb.html#command-line-interface)27  - [Команды отладчика](https://python-all.ru/3.16/library/pdb.html#debugger-commands)28- [`profiling` – профилировщики Python](https://python-all.ru/3.16/library/profiling.html)2930  - [Введение в профилирование](https://python-all.ru/3.16/library/profiling.html#introduction-to-profiling)31  - [Выбор профилировщика](https://python-all.ru/3.16/library/profiling.html#choosing-a-profiler)3233    - [Когда использовать статистическую выборку](https://python-all.ru/3.16/library/profiling.html#when-to-use-statistical-sampling)34    - [Когда использовать детерминированную трассировку](https://python-all.ru/3.16/library/profiling.html#when-to-use-deterministic-tracing)35  - [Быстрый старт](https://python-all.ru/3.16/library/profiling.html#quick-start)3637    - [Статистическое профилирование](https://python-all.ru/3.16/library/profiling.html#statistical-profiling)38    - [Детерминированное профилирование](https://python-all.ru/3.16/library/profiling.html#deterministic-profiling)39  - [Понимание вывода профилировщика](https://python-all.ru/3.16/library/profiling.html#understanding-profile-output)40  - [Совместимость с устаревшим кодом](https://python-all.ru/3.16/library/profiling.html#legacy-compatibility)4142    - [`profiling.tracing` – детерминированный профилировщик](https://python-all.ru/3.16/library/profiling.tracing.html)4344      - [Что такое детерминированное профилирование?](https://python-all.ru/3.16/library/profiling.tracing.html#what-is-deterministic-profiling)45      - [Интерфейс командной строки](https://python-all.ru/3.16/library/profiling.tracing.html#command-line-interface)46      - [Примеры программного использования](https://python-all.ru/3.16/library/profiling.tracing.html#programmatic-usage-examples)4748        - [Базовое профилирование](https://python-all.ru/3.16/library/profiling.tracing.html#basic-profiling)49        - [Использование класса `Profile`](https://python-all.ru/3.16/library/profiling.tracing.html#using-the-profile-class)50      - [Справочник модуля](https://python-all.ru/3.16/library/profiling.tracing.html#module-reference)51      - [Использование пользовательского таймера](https://python-all.ru/3.16/library/profiling.tracing.html#using-a-custom-timer)52      - [Ограничения](https://python-all.ru/3.16/library/profiling.tracing.html#limitations)53    - [`profiling.sampling` – Статистический профилировщик](https://python-all.ru/3.16/library/profiling.sampling.html)5455      - [Что такое статистическое профилирование?](https://python-all.ru/3.16/library/profiling.sampling.html#what-is-statistical-profiling)5657        - [Как оценивается время](https://python-all.ru/3.16/library/profiling.sampling.html#how-time-is-estimated)58        - [Когда использовать другой подход](https://python-all.ru/3.16/library/profiling.sampling.html#when-to-use-a-different-approach)59      - [Краткие примеры](https://python-all.ru/3.16/library/profiling.sampling.html#quick-examples)60      - [Команды](https://python-all.ru/3.16/library/profiling.sampling.html#commands)6162        - [Команда `run`](https://python-all.ru/3.16/library/profiling.sampling.html#the-run-command)63        - [Команда `attach`](https://python-all.ru/3.16/library/profiling.sampling.html#the-attach-command)64        - [Команда `dump`](https://python-all.ru/3.16/library/profiling.sampling.html#the-dump-command)65        - [Команда `replay`](https://python-all.ru/3.16/library/profiling.sampling.html#the-replay-command)66        - [Профилирование в продакшене](https://python-all.ru/3.16/library/profiling.sampling.html#profiling-in-production)67        - [Требования к платформе](https://python-all.ru/3.16/library/profiling.sampling.html#platform-requirements)68        - [Совместимость версий](https://python-all.ru/3.16/library/profiling.sampling.html#version-compatibility)69      - [Настройка сэмплирования](https://python-all.ru/3.16/library/profiling.sampling.html#sampling-configuration)7071        - [Частота и длительность сэмплирования](https://python-all.ru/3.16/library/profiling.sampling.html#sampling-rate-and-duration)72        - [Выбор потоков](https://python-all.ru/3.16/library/profiling.sampling.html#thread-selection)73        - [Режим блокировки](https://python-all.ru/3.16/library/profiling.sampling.html#blocking-mode)74        - [Специальные кадры](https://python-all.ru/3.16/library/profiling.sampling.html#special-frames)75        - [Профилирование с учётом опкодов](https://python-all.ru/3.16/library/profiling.sampling.html#opcode-aware-profiling)76        - [Статистика в реальном времени](https://python-all.ru/3.16/library/profiling.sampling.html#real-time-statistics)77        - [Профилирование подпроцессов](https://python-all.ru/3.16/library/profiling.sampling.html#subprocess-profiling)78        - [Эффективность сэмплирования](https://python-all.ru/3.16/library/profiling.sampling.html#sampling-efficiency)79      - [Режимы профилирования](https://python-all.ru/3.16/library/profiling.sampling.html#profiling-modes)8081        - [Режим реального времени](https://python-all.ru/3.16/library/profiling.sampling.html#wall-clock-mode)82        - [Режим ЦП](https://python-all.ru/3.16/library/profiling.sampling.html#cpu-mode)83        - [Сравнение профилей реального времени и ЦП](https://python-all.ru/3.16/library/profiling.sampling.html#comparing-wall-clock-and-cpu-profiles)84        - [Режим GIL](https://python-all.ru/3.16/library/profiling.sampling.html#gil-mode)85        - [Режим исключений](https://python-all.ru/3.16/library/profiling.sampling.html#exception-mode)86      - [Форматы вывода](https://python-all.ru/3.16/library/profiling.sampling.html#output-formats)8788        - [Формат pstats](https://python-all.ru/3.16/library/profiling.sampling.html#pstats-format)89        - [Формат свёрнутых стеков](https://python-all.ru/3.16/library/profiling.sampling.html#collapsed-stacks-format)90        - [Формат флейм-графа](https://python-all.ru/3.16/library/profiling.sampling.html#flame-graph-format)9192          - [Дифференциальные флейм-графы](https://python-all.ru/3.16/library/profiling.sampling.html#differential-flame-graphs)93        - [Формат Gecko](https://python-all.ru/3.16/library/profiling.sampling.html#gecko-format)94        - [Формат тепловой карты](https://python-all.ru/3.16/library/profiling.sampling.html#heatmap-format)95        - [Двоичный формат](https://python-all.ru/3.16/library/profiling.sampling.html#binary-format)96      - [Рабочий процесс записи и воспроизведения](https://python-all.ru/3.16/library/profiling.sampling.html#record-and-replay-workflow)97      - [Режим реального времени](https://python-all.ru/3.16/library/profiling.sampling.html#live-mode)9899        - [Команды клавиатуры](https://python-all.ru/3.16/library/profiling.sampling.html#keyboard-commands)100      - [Профилирование с учётом асинхронности](https://python-all.ru/3.16/library/profiling.sampling.html#async-aware-profiling)101102        - [Асинхронные режимы](https://python-all.ru/3.16/library/profiling.sampling.html#async-modes)103        - [Маркеры задач и восстановление стеков](https://python-all.ru/3.16/library/profiling.sampling.html#task-markers-and-stack-reconstruction)104        - [Ограничения параметров](https://python-all.ru/3.16/library/profiling.sampling.html#option-restrictions)105      - [Интерфейс командной строки](https://python-all.ru/3.16/library/profiling.sampling.html#command-line-interface)106107        - [Глобальные параметры](https://python-all.ru/3.16/library/profiling.sampling.html#global-options)108        - [Параметры дампа](https://python-all.ru/3.16/library/profiling.sampling.html#dump-options)109        - [Параметры сэмплирования](https://python-all.ru/3.16/library/profiling.sampling.html#sampling-options)110        - [Параметры режима](https://python-all.ru/3.16/library/profiling.sampling.html#mode-options)111        - [Параметры вывода](https://python-all.ru/3.16/library/profiling.sampling.html#output-options)112        - [Параметры отображения pstats](https://python-all.ru/3.16/library/profiling.sampling.html#pstats-display-options)113        - [Параметры команды запуска](https://python-all.ru/3.16/library/profiling.sampling.html#run-command-options)114- [`pstats` – Статистика для профилировщиков](https://python-all.ru/3.16/library/pstats.html)115116  - [Чтение и отображение данных профилирования](https://python-all.ru/3.16/library/pstats.html#reading-and-displaying-profile-data)117118    - [Работа со статистикой](https://python-all.ru/3.16/library/pstats.html#working-with-statistics)119    - [Фильтрация вывода](https://python-all.ru/3.16/library/pstats.html#filtering-output)120    - [Анализ взаимосвязей вызовов](https://python-all.ru/3.16/library/pstats.html#analyzing-call-relationships)121    - [Объединение нескольких профилей](https://python-all.ru/3.16/library/pstats.html#combining-multiple-profiles)122  - [Класс `Stats`](https://python-all.ru/3.16/library/pstats.html#the-stats-class)123  - [Интерфейс командной строки](https://python-all.ru/3.16/library/pstats.html#command-line-interface)124- [`timeit` – Измерение времени выполнения небольших фрагментов кода](https://python-all.ru/3.16/library/timeit.html)125126  - [Базовые примеры](https://python-all.ru/3.16/library/timeit.html#basic-examples)127  - [Интерфейс Python](https://python-all.ru/3.16/library/timeit.html#python-interface)128  - [Интерфейс командной строки](https://python-all.ru/3.16/library/timeit.html#command-line-interface)129  - [Примеры](https://python-all.ru/3.16/library/timeit.html#examples)130- [`trace` – Трассировка или отслеживание выполнения операторов Python](https://python-all.ru/3.16/library/trace.html)131132  - [Использование командной строки](https://python-all.ru/3.16/library/trace.html#command-line-usage)133134    - [Основные параметры](https://python-all.ru/3.16/library/trace.html#main-options)135    - [Модификаторы](https://python-all.ru/3.16/library/trace.html#modifiers)136    - [Фильтры](https://python-all.ru/3.16/library/trace.html#filters)137  - [Программный интерфейс](https://python-all.ru/3.16/library/trace.html#programmatic-interface)138- [`tracemalloc` – Трассировка выделений памяти](https://python-all.ru/3.16/library/tracemalloc.html)139140  - [Примеры](https://python-all.ru/3.16/library/tracemalloc.html#examples)141142    - [Отображение первых 10](https://python-all.ru/3.16/library/tracemalloc.html#display-the-top-10)143    - [Вычисление различий](https://python-all.ru/3.16/library/tracemalloc.html#compute-differences)144    - [Получение трассировки для блока памяти](https://python-all.ru/3.16/library/tracemalloc.html#get-the-traceback-of-a-memory-block)145    - [Удобный вывод топа](https://python-all.ru/3.16/library/tracemalloc.html#pretty-top)146147      - [Запись текущего и пикового размера всех отслеживаемых блоков памяти](https://python-all.ru/3.16/library/tracemalloc.html#record-the-current-and-peak-size-of-all-traced-memory-blocks)148  - [API](https://python-all.ru/3.16/library/tracemalloc.html#api)149150    - [Функции](https://python-all.ru/3.16/library/tracemalloc.html#functions)151    - [DomainFilter](https://python-all.ru/3.16/library/tracemalloc.html#domainfilter)152    - [Filter](https://python-all.ru/3.16/library/tracemalloc.html#filter)153    - [Frame](https://python-all.ru/3.16/library/tracemalloc.html#frame)154    - [Snapshot](https://python-all.ru/3.16/library/tracemalloc.html#snapshot)155    - [Statistic](https://python-all.ru/3.16/library/tracemalloc.html#statistic)156    - [StatisticDiff](https://python-all.ru/3.16/library/tracemalloc.html#statisticdiff)157    - [Trace](https://python-all.ru/3.16/library/tracemalloc.html#trace)158    - [Traceback](https://python-all.ru/3.16/library/tracemalloc.html#traceback)159