summaryrefslogtreecommitdiff
path: root/unix/modffi.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 /unix/modffi.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 'unix/modffi.c')
-rw-r--r--unix/modffi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/unix/modffi.c b/unix/modffi.c
index cae16c579..74194e2cc 100644
--- a/unix/modffi.c
+++ b/unix/modffi.c
@@ -194,7 +194,8 @@ STATIC mp_obj_t make_func(mp_obj_t rettype_in, void *func, mp_obj_t argtypes_in)
o->rettype = *rettype;
o->argtypes = argtypes;
- mp_obj_t iterable = mp_getiter(argtypes_in);
+ mp_obj_iter_buf_t iter_buf;
+ mp_obj_t iterable = mp_getiter(argtypes_in, &iter_buf);
mp_obj_t item;
int i = 0;
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
@@ -251,7 +252,8 @@ STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t
o->rettype = *rettype;
- mp_obj_t iterable = mp_getiter(paramtypes_in);
+ mp_obj_iter_buf_t iter_buf;
+ mp_obj_t iterable = mp_getiter(paramtypes_in, &iter_buf);
mp_obj_t item;
int i = 0;
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {