8000 gh-128262: Allow specialization of calls to classes with __slots__ (G… · python/cpython@7ef4907 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ef4907

Browse files
gh-128262: Allow specialization of calls to classes with __slots__ (GH-128263)
1 parent dafe7a4 commit 7ef4907

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,13 +3765,15 @@ dummy_func(
37653765
DEOPT_IF(!PyType_Check(callable_o));
37663766
PyTypeObject *tp = (PyTypeObject *)callable_o;
37673767
DEOPT_IF(FT_ATOMIC_LOAD_UINT32_RELAXED(tp->tp_version_tag) != type_version);
3768-
assert(tp->tp_flags & Py_TPFLAGS_INLINE_VALUES);
3768+
assert(tp->tp_new == PyBaseObject_Type.tp_new);
3769+
assert(tp->tp_flags & Py_TPFLAGS_HEAPTYPE);
3770+
assert(tp->tp_alloc == PyType_GenericAlloc);
37693771
PyHeapTypeObject *cls = (PyHeapTypeObject *)callable_o;
37703772
PyFunctionObject *init_func = (PyFunctionObject *)FT_ATOMIC_LOAD_PTR_ACQUIRE(cls->_spec_cache.init);
37713773
PyCodeObject *code = (PyCodeObject *)init_func->func_code;
37723774
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize + _Py_InitCleanup.co_framesize));
37733775
STAT_INC(CALL, hit);
3774-
PyObject *self_o = _PyType_NewManagedObject(tp);
3776+
PyObject *self_o = PyType_GenericAlloc(tp, 0);
37753777
if (self_o == NULL) {
37763778
ERROR_NO_POP();
37773779
}

Python/executor_cases.c.h

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/specialize.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,10 +2002,6 @@ get_init_for_simple_managed_python_class(PyTypeObject *tp, unsigned int *tp_vers
20022002
return NULL;
20032003
}
20042004
unsigned long tp_flags = PyType_GetFlags(tp);
2005-
if ((tp_flags & Py_TPFLAGS_INLINE_VALUES) == 0) {
2006-
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_INIT_NOT_INLINE_VALUES);
2007-
return NULL;
2008-
}
20092005
if (!(tp_flags & Py_TPFLAGS_HEAPTYPE)) {
20102006
/* Is this possible? */
20112007
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_EXPECTED_ERROR);

0 commit comments

Comments
 (0)
0