Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-145481: Optimize frozendict lookup in free threading#145482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vstinner wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromvstinner:frozendict_lookup
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletionsObjects/dictobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1280,7 +1280,10 @@ _Py_dict_lookup(PyDictObject *mp, PyObject *key, Py_hash_t hash, PyObject **valu
DictKeysKindkind;
Py_ssize_tix;

_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(mp);
if (!PyFrozenDict_CheckExact(mp)) {
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(mp);
}

start:
dk=mp->ma_keys;
kind=dk->dk_kind;
Expand DownExpand Up@@ -1518,13 +1521,19 @@ dictkeys_generic_lookup_threadsafe(PyDictObject *mp, PyDictKeysObject* dk, PyObj
Py_ssize_t
_Py_dict_lookup_threadsafe(PyDictObject*mp,PyObject*key,Py_hash_thash,PyObject**value_addr)
{
ensure_shared_on_read(mp);

if (PyFrozenDict_CheckExact(mp)) {
Py_ssize_tix=_Py_dict_lookup(mp,key,hash,value_addr);
Py_XNewRef(*value_addr);
returnix;
}

PyDictKeysObject*dk;
DictKeysKindkind;
Py_ssize_tix;
PyObject*value;

ensure_shared_on_read(mp);

dk=_Py_atomic_load_ptr(&mp->ma_keys);
kind=dk->dk_kind;

Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp