summaryrefslogtreecommitdiff
path: root/stmhal
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 /stmhal
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 'stmhal')
-rw-r--r--stmhal/pybstdio.c4
-rw-r--r--stmhal/uart.c2
-rw-r--r--stmhal/usb.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/stmhal/pybstdio.c b/stmhal/pybstdio.c
index dec4f227a..9b1bfff90 100644
--- a/stmhal/pybstdio.c
+++ b/stmhal/pybstdio.c
@@ -120,7 +120,7 @@ STATIC const mp_obj_type_t stdio_obj_type = {
.name = MP_QSTR_FileIO,
// TODO .make_new?
.print = stdio_obj_print,
- .getiter = mp_identity,
+ .getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &stdio_obj_stream_p,
.locals_dict = (mp_obj_t)&stdio_locals_dict,
@@ -153,7 +153,7 @@ STATIC const mp_obj_type_t stdio_buffer_obj_type = {
{ &mp_type_type },
.name = MP_QSTR_FileIO,
.print = stdio_obj_print,
- .getiter = mp_identity,
+ .getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &stdio_buffer_obj_stream_p,
.locals_dict = (mp_obj_t)&stdio_locals_dict,
diff --git a/stmhal/uart.c b/stmhal/uart.c
index d53ca5b80..4fae3a80c 100644
--- a/stmhal/uart.c
+++ b/stmhal/uart.c
@@ -1037,7 +1037,7 @@ const mp_obj_type_t pyb_uart_type = {
.name = MP_QSTR_UART,
.print = pyb_uart_print,
.make_new = pyb_uart_make_new,
- .getiter = mp_identity,
+ .getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &uart_stream_p,
.locals_dict = (mp_obj_t)&pyb_uart_locals_dict,
diff --git a/stmhal/usb.c b/stmhal/usb.c
index c413ce4ba..f71c70665 100644
--- a/stmhal/usb.c
+++ b/stmhal/usb.c
@@ -518,7 +518,7 @@ const mp_obj_type_t pyb_usb_vcp_type = {
.name = MP_QSTR_USB_VCP,
.print = pyb_usb_vcp_print,
.make_new = pyb_usb_vcp_make_new,
- .getiter = mp_identity,
+ .getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &pyb_usb_vcp_stream_p,
.locals_dict = (mp_obj_t)&pyb_usb_vcp_locals_dict,