Set Py_TPFLAGS_METHOD_DESCRIPTOR on PyGIFunctionInfo_Type
This MR sets the Py_TPFLAGS_METHOD_DESCRIPTOR
flag on PyGIFunctionInfo_Type
, signalling to the interpreter that it's descriptor behaviour matches that of the standard function type and that it is safe to bypass creating a bound method object and call method(self, args...)
directly.
At present, the behaviour only matches for FunctionInfo objects representing methods: constructors and non-methods present different descriptor behaviour. I've handled this by removing that code from _function_info_descr_get
and have MetaClassHelper._setup_methods
wrap constructors and non-methods in classmethod
and staticmethod
respectively.
These changes should also help the specializing interpreter classify methods better, potentially opening up other optimisation opportunities: