pep-550: Add a note why HAMT is better than dict.copy() (#347)

* pep-550: Add a note why HAMT is better than dict.copy()

* pep-550: Drop now unused images
This commit is contained in:
Yury Selivanov 2017-08-15 23:27:54 -04:00 committed by GitHub
parent f67bb4e465
commit 5207a074cf
5 changed files with 18 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

View File

@ -1041,6 +1041,11 @@ This proposal preserves 100% backwards compatibility.
Appendix: HAMT Performance
==========================
First, while investigating possibilities of how to implement an
immutable mapping in CPython, we were able to improve the efficiency
of ``dict.copy()`` up to 5 times: [4]_. All benchmarks in this
section were run against the optimized dict.
To assess if HAMT can be used for Execution Context, we implemented
it in CPython [7]_.
@ -1067,6 +1072,19 @@ considering how well Python dicts are optimized.
Note, that according to [8]_, HAMT design can be further improved.
There is a limitation of Python ``dict`` design which makes HAMT
the preferred choice for immutable mapping implementation:
dicts need to be resized periodically, and resize is expensive.
The ``dict.copy()`` optimization we were able to do (see [4]_) will
only work for dicts that had no deleted items. Dicts that had
deleted items need to be resized during ``copy()``, which makes it
much slower.
Because adding and deleting items from LocalContext is a very common
operation, we would not be able to always use the optimized
``dict.copy()`` for LocalContext, frequently resorting to use the
slower version of it.
Acknowledgments
===============