diff options
| author | Damien George | 2016-01-09 23:14:54 +0000 |
|---|---|---|
| committer | Damien George | 2017-02-16 18:38:06 +1100 |
| commit | ae8d86758631e62466a55d179897d2111c3cb1c1 (patch) | |
| tree | 1852733b57cd4334727203e11d5af76243615636 /py/objfilter.c | |
| parent | 101886f5291fdbef07ba70d386c5e3e644b71cfb (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/objfilter.c')
| -rw-r--r-- | py/objfilter.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objfilter.c b/py/objfilter.c index a5c85b2ce..a655b8a78 100644 --- a/py/objfilter.c +++ b/py/objfilter.c @@ -39,7 +39,7 @@ STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t mp_obj_filter_t *o = m_new_obj(mp_obj_filter_t); o->base.type = type; o->fun = args[0]; - o->iter = mp_getiter(args[1]); + o->iter = mp_getiter(args[1], NULL); return MP_OBJ_FROM_PTR(o); } @@ -65,7 +65,7 @@ const mp_obj_type_t mp_type_filter = { { &mp_type_type }, .name = MP_QSTR_filter, .make_new = filter_make_new, - .getiter = mp_identity, + .getiter = mp_identity_getiter, .iternext = filter_iternext, }; |
