Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
3f522624
Commit
3f522624
authored
Jun 03, 2014
by
Damien George
Browse files
py: Allow tail call optimisation in mp_call_function_n_kw.
This saves 4 words of stack space per Python call.
parent
65ec3320
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/objtype.c
View file @
3f522624
...
...
@@ -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
);
...
...
py/runtime.c
View file @
3f522624
...
...
@@ -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
)));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment