Skip to content

Commit fea1f82

Browse files
committed
#4930: Slightly cleaner (and faster) code in type creation:
compare slots by address, not by name.
1 parent 786fe0a commit fea1f82

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Objects/typeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6114,7 +6114,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
61146114
else if (Py_TYPE(descr) == &PyCFunction_Type &&
61156115
PyCFunction_GET_FUNCTION(descr) ==
61166116
(PyCFunction)tp_new_wrapper &&
6117-
strcmp(p->name, "__new__") == 0)
6117+
ptr == (void**)&type->tp_new)
61186118
{
61196119
/* The __new__ wrapper is not a wrapper descriptor,
61206120
so must be special-cased differently.
@@ -6134,7 +6134,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
61346134
point out a bug in this reasoning a beer. */
61356135
}
61366136
else if (descr == Py_None &&
6137-
strcmp(p->name, "__hash__") == 0) {
6137+
ptr == (void**)&type->tp_hash) {
61386138
/* We specifically allow __hash__ to be set to None
61396139
to prevent inheritance of the default
61406140
implementation from object.__hash__ */

0 commit comments

Comments
 (0)