Commit 5f8b597e authored by Robert Bradshaw's avatar Robert Bradshaw

Added optimize_simple_methods to make it possible to accept keywords in 1-arg functions

parent f441bb7d
...@@ -1252,7 +1252,7 @@ class DefNode(FuncDefNode): ...@@ -1252,7 +1252,7 @@ class DefNode(FuncDefNode):
any_type_tests_needed = 0 any_type_tests_needed = 0
# Use the simpler calling signature for zero- and one-argument functions. # Use the simpler calling signature for zero- and one-argument functions.
if not self.entry.is_special and not self.star_arg and not self.starstar_arg: if not self.entry.is_special and not self.star_arg and not self.starstar_arg:
if self.entry.signature is TypeSlots.pyfunction_signature: if self.entry.signature is TypeSlots.pyfunction_signature and Options.optimize_simple_methods:
if len(self.args) == 0: if len(self.args) == 0:
self.entry.signature = TypeSlots.pyfunction_noargs self.entry.signature = TypeSlots.pyfunction_noargs
elif len(self.args) == 1: elif len(self.args) == 1:
......
...@@ -45,3 +45,8 @@ lookup_module_cpdef = 0 ...@@ -45,3 +45,8 @@ lookup_module_cpdef = 0
# checking for NULL on every use, and can decref rather than xdecref at the end. # checking for NULL on every use, and can decref rather than xdecref at the end.
# WARNING: This is a work in progress, may currently segfault. # WARNING: This is a work in progress, may currently segfault.
init_local_none = 1 init_local_none = 1
# Optimize no argument and one argument methods by using the METH_O and METH_NOARGS
# calling conventions. These are faster calling conventions, but disallow the use of
# keywords (which, admittedly, are of little use in these cases).
optimize_simple_methods = 1
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