py/runtime: Don't allocate iter buf for user-defined types.

A user-defined type that defines __iter__ doesn't need any memory to be
pre-allocated for its iterator (because it can't use such memory).  So
optimise for this case by not allocating the iter-buf.
This commit is contained in:
Damien George
2019-11-13 21:05:34 +11:00
parent 11b4524b39
commit aacd618939
3 changed files with 19 additions and 7 deletions

View File

@@ -51,4 +51,7 @@ mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
// this needs to be exposed for the above macros to work correctly
mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
// this needs to be exposed for mp_getiter
mp_obj_t mp_obj_instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);
#endif // MICROPY_INCLUDED_PY_OBJTYPE_H