From: Robert Bradshaw Date: Sat, 29 Mar 2008 22:09:01 +0000 (-0700) Subject: Added optimize_simple_methods to make it possible to accept keywords in 1-arg functions X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5f8b597eb6b577f9fb8bc0cbdf7546d99961d0d0;p=cython.git Added optimize_simple_methods to make it possible to accept keywords in 1-arg functions --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 58cda726..43a6d413 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1252,7 +1252,7 @@ class DefNode(FuncDefNode): any_type_tests_needed = 0 # 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 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: self.entry.signature = TypeSlots.pyfunction_noargs elif len(self.args) == 1: diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py index 03852327..0b029f90 100644 --- a/Cython/Compiler/Options.py +++ b/Cython/Compiler/Options.py @@ -45,3 +45,8 @@ lookup_module_cpdef = 0 # 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. 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