Commit e3e7b8c8 authored by Stefan Behnel's avatar Stefan Behnel

Keep METH_O optimisation when "always_allow_keywords" is enabled but the...

Keep METH_O optimisation when "always_allow_keywords" is enabled but the function has only one pos-only argument.
parent b8338997
......@@ -3016,8 +3016,10 @@ class DefNode(FuncDefNode):
if self.decorators:
error(self.pos, "special functions of cdef classes cannot have decorators")
self.entry.trivial_signature = len(self.args) == 1 and not (self.star_arg or self.starstar_arg)
elif not env.directives['always_allow_keywords'] and not (self.star_arg or self.starstar_arg):
# Use the simpler calling signature for zero- and one-argument functions.
elif not (self.star_arg or self.starstar_arg) and (
not env.directives['always_allow_keywords']
or all([arg.pos_only for arg in self.args])):
# Use the simpler calling signature for zero- and one-argument pos-only functions.
if self.entry.signature is TypeSlots.pyfunction_signature:
if len(self.args) == 0:
self.entry.signature = TypeSlots.pyfunction_noargs
......
# cython: always_allow_keywords=True
# mode: run
# tag: posonly
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment