-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
GH-137759:Limit _PyObject_HashFast to dicts keys, rename it, and mark it as Py_ALWAYS_INLINE #137828
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
GH-137759:Limit _PyObject_HashFast to dicts keys, rename it, and mark it as Py_ALWAYS_INLINE #137828
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -836,9 +836,14 @@ _PyObject_IS_GC(PyObject *obj) | |
| && (type->tp_is_gc == NULL || type->tp_is_gc(obj))); | ||
| } | ||
|
|
||
| // Fast inlined version of PyObject_Hash() | ||
| static inline Py_hash_t | ||
| _PyObject_HashFast(PyObject *op) | ||
| // Fast inlined version of PyObject_Hash(). Dictionaries are very | ||
| // likely to include string keys (class and instance attributes, | ||
| // json, ...) so we include a fast path for strings. | ||
| // This function should not be used in a collection if str is not | ||
| // very likely, since it is slower than PyObject_Hash() on types | ||
| // other than str. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a sentence to explain explicitly that the function is used for dict since dict keys are likely strings, but it's not used for set since set items are less likely to be strings.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And add a reference to the issue: |
||
| static inline Py_ALWAYS_INLINE Py_hash_t | ||
| _PyObject_HashDictKey(PyObject *op) | ||
| { | ||
| if (PyUnicode_CheckExact(op)) { | ||
| Py_hash_t hash = PyUnstable_Unicode_GET_CACHED_HASH(op); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.