From d3439d0c6065bc60a9c4c915f4a1a3ffa796cf33 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 2 Jun 2014 19:37:55 +0300 Subject: py: Instead of having "debug on" var, have "optimization level" var. This allows to have multiple "optimization" levels (CPython has two (-OO removes docstrings), we can have more). --- py/runtime.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'py/runtime.c') diff --git a/py/runtime.c b/py/runtime.c index ecaf40deb..27a5ed543 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -45,6 +45,7 @@ #include "bc.h" #include "smallint.h" #include "objgenerator.h" +#include "lexer.h" #if 0 // print debugging info #define DEBUG_PRINT (1) @@ -74,8 +75,8 @@ void mp_init(void) { MICROPY_PORT_INIT_FUNC; #endif - // __debug__ enabled by default - mp_set_debug(true); + // optimization disabled by default + mp_optimise_value = 0; // init global module stuff mp_module_init(); -- cgit v1.2.3 From 3f5226246517be2f28d4f23d6e4c202047915f83 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 3 Jun 2014 13:40:16 +0100 Subject: py: Allow tail call optimisation in mp_call_function_n_kw. This saves 4 words of stack space per Python call. --- py/runtime.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'py/runtime.c') diff --git a/py/runtime.c b/py/runtime.c index 27a5ed543..f13cc1d89 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -526,10 +526,7 @@ mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, uint n_args, uint n_kw, const mp // do the call if (type->call != NULL) { - mp_obj_t res = type->call(fun_in, n_args, n_kw, args); - if (res != NULL) { - return res; - } + return type->call(fun_in, n_args, n_kw, args); } nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not callable", mp_obj_get_type_str(fun_in))); -- cgit v1.2.3