Skip to content

Commit a3271f2

Browse files
author
Anastasiia Shcherbakova
committed
added a visual representation of python lists resizing
1 parent 58857a6 commit a3271f2

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

episodes/fig/python_lists.png

448 KB
Loading

episodes/optimisation-data-structures-algorithms.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ CPython for example uses [`newsize + (newsize >> 3) + 6`](https://github.com/pyt
6363

6464
![The relationship between the number of appends to an empty list, and the number of internal resizes in CPython.](episodes/fig/cpython_list_allocations.png){alt='A line graph displaying the relationship between the number of calls to append() and the number of internal resizes of a CPython list. It has a logarithmic relationship, at 1 million appends there have been 84 internal resizes.'}
6565

66+
![Visual note on resizing behaviour of Python lists.](episodes/fig/python_lists.png){alt='Small cheat note for better visualization of Python lists.'}
67+
68+
6669
This has two implications:
6770

6871
* If you are creating large static lists, they will use up to 12.5% excess memory.

0 commit comments

Comments
 (0)