# py-example **Repository Path**: bytesifter/py-example ## Basic Information - **Project Name**: py-example - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-20 - **Last Updated**: 2026-06-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # py-example Python 内存管理与并发机制的示例测试集。 测试内容来源于以下两篇 CSDN 技术文章: - [Python 内存管理深度解析](https://blog.csdn.net/weixin_41120248/article/details/162014185) - [Python 并发深度解析](https://blog.csdn.net/weixin_41120248/article/details/162016508) ## 快速开始 ```bash # 安装依赖(仅 pytest) uv sync # 运行全部测试 uv run pytest tests/ -v # 仅运行内存管理测试 uv run pytest tests/test_memory/ -v # 仅运行并发测试 uv run pytest tests/test_concurrency/ -v # 运行单个测试文件 uv run pytest tests/test_memory/test_refcount.py -v # 运行单个测试函数 uv run pytest tests/test_memory/test_refcount.py::test_del_decreases_refcount -v ``` ## 目录结构 ``` py-example/ ├── README.md ├── docs/ │ └── tests.md # 测试用例详解 ├── tests/ │ ├── __init__.py │ ├── test_memory/ # 内存管理 (16 files, 89 tests) │ │ ├── test_object_sizes.py │ │ ├── test_mutable_vs_immutable.py │ │ ├── test_small_int_cache.py │ │ ├── test_string_interning.py │ │ ├── test_refcount.py │ │ ├── test_weakref.py │ │ ├── test_circular_ref.py │ │ ├── test_generational_gc.py │ │ ├── test_memory_limit.py │ │ ├── test_slots.py │ │ ├── test_memoryview.py │ │ ├── test_container_expansion.py │ │ ├── test_generator_vs_list.py │ │ ├── test_array_vs_list.py │ │ ├── test_tracemalloc.py │ │ └── test_memory_leak_scenarios.py │ └── test_concurrency/ # 并发机制 (19 files, 66 tests) │ ├── test_gil_cpu_vs_io.py │ ├── test_thread_basics.py │ ├── test_thread_sync.py │ ├── test_thread_local.py │ ├── test_thread_pool.py │ ├── test_multiprocess_basics.py │ ├── test_process_pool.py │ ├── test_ipc.py │ ├── test_shared_memory.py │ ├── test_asyncio_basics.py │ ├── test_asyncio_task.py │ ├── test_futures_unified.py │ ├── test_asyncio_hybrid.py │ ├── test_gil_atomicity.py │ ├── test_race_condition.py │ ├── test_asyncio_blocking.py │ ├── test_pickle_trap.py │ ├── test_deadlock.py │ ├── test_thread_dump.py │ └── test_asyncio_debug.py └── openspec/ ``` ## 平台说明 - 依赖仅 pytest,通过 uv 管理 - 3 个 Unix 专属测试(`test_memory_limit.py`)在 Windows 上自动跳过 - 测试在 Python 3.8+ 上运行,`test_shared_memory.py` 需要 Python 3.8+ ## 详细文档 每个测试函数的详细说明见 [docs/tests.md](docs/tests.md)。