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.
diff --git a/py/objzip.c b/py/objzip.c
index 6edefc3..5d9ba48 100644
--- a/py/objzip.c
+++ b/py/objzip.c
@@ -43,7 +43,7 @@
o->base.type = type;
o->n_iters = n_args;
for (mp_uint_t i = 0; i < n_args; i++) {
- o->iters[i] = mp_getiter(args[i]);
+ o->iters[i] = mp_getiter(args[i], NULL);
}
return MP_OBJ_FROM_PTR(o);
}
@@ -71,6 +71,6 @@
{ &mp_type_type },
.name = MP_QSTR_zip,
.make_new = zip_make_new,
- .getiter = mp_identity,
+ .getiter = mp_identity_getiter,
.iternext = zip_iternext,
};