Argument clinic: improve generated code for self converter type checks #101409
Labels
expert-argument-clinic
performance
Performance or resource usage
type-feature
A feature request or enhancement
Feature or enhancement
Currently, typically for
__new__and__init__methods, Argument Clinic will spell out theselftype check as such:prefixis a slightly modified variant oftype_object, depending on if the latter is a pointer. This works swell in most cases, but with module state and heap types, the generated code is not optimal. First, let's just quote the AC docs on how to declare a class:For heap types with module state, you'd typically do something like this:
Currently, this generates clinic code like this:
... potentially calling
PyType_GetModuleByDeftwice in the self type check.Pitch
Suggesting to modify clinic to store the self type pointer in a local variable, and use that variable in the self type check. Proof-of-concept diff from the
_sqliteextension module clinic codePrevious discussion
#101302 (comment)
Linked PRs
The text was updated successfully, but these errors were encountered: