Skip to content

Commit 8f81fdc

Browse files
committed
docs: redesign long/list/dict/set diagrams as SVG
Replace the remaining raster diagrams with hand-built SVGs in the shared muted style: integer storage / x_add / x_sub, PyListObject layout, dict memory layout (PyDictObject → PyDictKeysObject → indices → entries) and the set insert sequence. Point the articles at the new .svg files.
1 parent 3e133c6 commit 8f81fdc

13 files changed

Lines changed: 537 additions & 9 deletions

File tree

objects/dict-object/dict-mem.svg

Lines changed: 89 additions & 0 deletions
Loading

objects/dict-object/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct _dictkeysobject {
127127
```
128128

129129
相关数据结构的内存布局为;
130-
![python_dict_mem](dict-mem.png)
130+
![python_dict_mem](dict-mem.svg)
131131

132132
## Python 字典示例
133133

Lines changed: 53 additions & 0 deletions
Loading

objects/list-object/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ lst.append(1)
3939

4040
其存储结构如下图
4141

42-
![PyList structure](PyListStructure.png)
42+
![PyList structure](PyListStructure.svg)
4343

4444

4545

objects/long-object/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ print(num)
387387

388388
如下图所示
389389

390-
![longobject storage](long-storage.png)
390+
![longobject storage](long-storage.svg)
391391

392392
注:这里的 30 是由 **PyLong_SHIFT** 决定的,64 位系统中,**PyLong_SHIFT** 为 30,否则 **PyLong_SHIFT** 为 15
393393

@@ -524,7 +524,7 @@ x_add(PyLongObject *a, PyLongObject *b)
524524

525525
加法运算函数 x_add 从 ob_digit 数组的低位开始依次按位相加,carry 做进位处理,然后处理 a 对象的高位数字,最后使用 long_normalize 函数调整 ob_size,确保 ob_digit[abs(ob_size)-1]不为零,这与普通四则运算的加法运算相同,只不过进位单元不同而已
526526

527-
![longobject x_add](long-x-add.png)
527+
![longobject x_add](long-x-add.svg)
528528

529529
`源文件:`[Objects/longobject.c](https://github.com/python/cpython/blob/v3.7.0/Objects/longobject.c#L3025)
530530

@@ -593,7 +593,7 @@ x_sub(PyLongObject *a, PyLongObject *b)
593593
与普通四则运算减法相同,数不够大则向高一位借位,
594594
减法运算函数 x_sub 的示例图如下,注:PyLong_SHIFT 为 30
595595
596-
![longobject x_sub](long-x-sub.png)
596+
![longobject x_sub](long-x-sub.svg)
597597
598598
### 整数相乘
599599
Lines changed: 45 additions & 0 deletions
Loading

objects/long-object/long-x-add.svg

Lines changed: 48 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)