summaryrefslogtreecommitdiffstatshomepage
path: root/py/obj.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/obj.c
parent101886f5291fdbef07ba70d386c5e3e644b71cfb (diff)
downloadmicropython-ae8d86758631e62466a55d179897d2111c3cb1c1.tar.gz
micropython-ae8d86758631e62466a55d179897d2111c3cb1c1.zip
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/obj.c')
-rw-r--r--py/obj.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/obj.c b/py/obj.c
index 1d0c80ab90..4534ef1b28 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -481,6 +481,11 @@ mp_obj_t mp_identity(mp_obj_t self) {
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity);
+mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf) {
+ (void)iter_buf;
+ return self;
+}
+
bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
mp_obj_type_t *type = mp_obj_get_type(obj);
if (type->buffer_p.get_buffer == NULL) {