py: Allow tail call optimisation in mp_call_function_n_kw.

This saves 4 words of stack space per Python call.
pull/654/head
Damien George 2014-06-03 13:40:16 +01:00
rodzic 65ec33200a
commit 3f52262465
2 zmienionych plików z 2 dodań i 5 usunięć

Wyświetl plik

@ -516,7 +516,7 @@ STATIC mp_obj_t instance_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp
mp_obj_t member[2] = {MP_OBJ_NULL};
mp_obj_class_lookup(self, self->base.type, MP_QSTR___call__, offsetof(mp_obj_type_t, call), member);
if (member[0] == MP_OBJ_NULL) {
return MP_OBJ_NULL;
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not callable", mp_obj_get_type_str(self_in)));
}
if (member[0] == MP_OBJ_SENTINEL) {
return mp_call_function_n_kw(self->subobj[0], n_args, n_kw, args);

Wyświetl plik

@ -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)));