[New-bugs-announce] [issue46845] dict: Use smaller entry for Unicode-key only dict.

Inada Naoki report at bugs.python.org
Thu Feb 24 02:40:55 EST 2022

New submission from Inada Naoki <songofacandy at gmail.com>:

Currently, PyDictKeyEntry is 24bytes (hash, key, and value).

We can drop the hash from entry when all keys are unicode, because unicode objects caches hash already.

This will cause some performance regression on microbenchmark because dict need one more indirect access to compare hash value.

On the other hand, this will reduce some RAM usage. Additionally, unlike docstrings and annotations, this includes much **hot** RAM. It will make Python more cache efficient.

This is work in progress code: https://github.com/methane/cpython/pull/43
pypeformance result is in the PR too.

components: Interpreter Core
messages: 413892
nosy: Mark.Shannon, methane, rhettinger
priority: normal
severity: normal
status: open
title: dict: Use smaller entry for Unicode-key only dict.
type: performance
versions: Python 3.11

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list