# 调试和分析

These libraries help you with Python development: the debugger enables you to step through code, analyze stack frames and set breakpoints etc., and the profilers run code and give you a detailed breakdown of execution times, allowing you to identify bottlenecks in your programs. Auditing events provide visibility into runtime behaviors that would otherwise require intrusive debugging or patching.

- Audit events table
- `bdb` --- Debugger framework
- `faulthandler` --- Dump the Python traceback
  - Dumping the traceback
  - Fault handler state
  - Dumping the tracebacks after a timeout
  - Dumping the traceback on a user signal
  - Issue with file descriptors
  - 示例
- `pdb` --- Python的调试器
  - Debugger Commands
- The Python Profilers
  - Introduction to the profilers
  - Instant User's Manual
  - `profile` and `cProfile` Module Reference
  - The `Stats` Class
  - What Is Deterministic Profiling?
  - Limitations
  - Calibration
  - Using a custom timer
- `timeit` --- 测量小代码片段的执行时间
  - 基本示例
  - Python 接口
  - 命令行界面
  - 示例
- `trace` --- Trace or track Python statement execution
  - Command-Line Usage
    - Main options
    - Modifiers
    - Filters
  - Programmatic Interface
- `tracemalloc` --- Trace memory allocations
  - 示例
    - Display the top 10
    - Compute differences
    - Get the traceback of a memory block
    - Pretty top
  - API
    - 函数
    - DomainFilter
    - Filter
    - Frame
    - Snapshot
    - Statistic
    - StatisticDiff
    - Trace
    - Traceback