Skip to content

gh-158788: Preserve metaclass __call__ in vectorcall optimization - #158789

Open
cocolato wants to merge 2 commits into
python:mainfrom
cocolato:bug/vec_call
Open

cocolato wants to merge 2 commits into
python:mainfrom
cocolato:bug/vec_call

Conversation

@cocolato

@cocolato cocolato commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

The vectorcall optimization for class calls can bypass a custom metaclass's __call__ after a call site specializes on a built-in class.

In CALL_BUILTIN_CLASS, the runtime guard accepts any class with a non-NULL tp_vectorcall, and the call handler invokes that pointer directly.

Require the class's metaclass to be exactly type in the runtime guard, matching the optimizer's existing assumption. Move the existing metaclass check before the immutable-type branch in specialize_class_call() so immutable classes with custom metaclasses also use the generic call path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant