Tag

list_resize

2 views collected around this technical thread.

Efficient Ops
Efficient Ops
Dec 27, 2018 · Fundamentals

Why Python Lists Aren’t Pre‑Allocated: Inside CPython’s Memory Management

Python’s list type appears flexible, but its underlying CPython implementation uses a dynamic resizing strategy without a pre‑allocated memory pool, allocating memory on demand via list_resize and PyMem_RESIZE, which this article explains through code analysis, memory size measurements, and practical recommendations.

CPythonMemory ManagementPerformance
0 likes · 13 min read
Why Python Lists Aren’t Pre‑Allocated: Inside CPython’s Memory Management
NetEase Game Operations Platform
NetEase Game Operations Platform
Dec 15, 2018 · Fundamentals

Understanding Python List Memory Allocation and Append Behavior

This article explains how Python lists manage memory during initialization and appends, examines CPython's internal allocation algorithm, demonstrates memory growth with practical code examples, and recommends using list comprehensions for more efficient list creation.

PerformancePythonappend
0 likes · 10 min read
Understanding Python List Memory Allocation and Append Behavior