aboutsummaryrefslogtreecommitdiff
path: root/py/objmap.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-01-09 23:14:54 +0000
committerDamien George <damien.p.george@gmail.com>2017-02-16 18:38:06 +1100
commitae8d86758631e62466a55d179897d2111c3cb1c1 (patch)
tree1852733b57cd4334727203e11d5af76243615636 /py/objmap.c
parent101886f5291fdbef07ba70d386c5e3e644b71cfb (diff)
py: Add iter_buf to getiter type method.
Allows to iterate over the following without allocating on the heap: - tuple - list - string, bytes - bytearray, array - dict (not dict.keys, dict.values, dict.items) - set, frozenset Allows to call the following without heap memory: - all, any, min, max, sum TODO: still need to allocate stack memory in bytecode for iter_buf.
Diffstat (limited to 'py/objmap.c')
-rw-r--r--py/objmap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objmap.c b/py/objmap.c
index ed0291435..0b2189016 100644
--- a/py/objmap.c
+++ b/py/objmap.c
@@ -43,7 +43,7 @@ STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
o->n_iters = n_args - 1;
o->fun = args[0];
for (mp_uint_t i = 0; i < n_args - 1; i++) {
- o->iters[i] = mp_getiter(args[i + 1]);
+ o->iters[i] = mp_getiter(args[i + 1], NULL);
}
return MP_OBJ_FROM_PTR(o);
}
@@ -68,6 +68,6 @@ const mp_obj_type_t mp_type_map = {
{ &mp_type_type },
.name = MP_QSTR_map,
.make_new = map_make_new,
- .getiter = mp_identity,
+ .getiter = mp_identity_getiter,
.iternext = map_iternext,
};