diff options
author | Damien George <damien.p.george@gmail.com> | 2018-06-12 15:06:11 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-06-12 15:06:11 +1000 |
commit | 035906419d925bf723dba21f9fbb22ca1c8021f1 (patch) | |
tree | 8202481c77ca6e5f02138bc58c4c5a1596577353 /py/mpstate.h | |
parent | 5042d98514cb498bcc3cf22b6fcaae8ab4cb768b (diff) |
extmod/uos_dupterm: Use native C stream methods on dupterm object.
This patch changes dupterm to call the native C stream methods on the
connected stream objects, instead of calling the Python readinto/write
methods. This is much more efficient for native stream objects like UART
and webrepl and doesn't require allocating a special dupterm array.
This change is a minor breaking change from the user's perspective because
dupterm no longer accepts pure user stream objects to duplicate on. But
with the recent addition of uio.IOBase it is possible to still create such
classes just by inheriting from uio.IOBase, for example:
import uio, uos
class MyStream(uio.IOBase):
def write(self, buf):
# existing write implementation
def readinto(self, buf):
# existing readinto implementation
uos.dupterm(MyStream())
Diffstat (limited to 'py/mpstate.h')
-rw-r--r-- | py/mpstate.h | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/py/mpstate.h b/py/mpstate.h index 199fd2cb6..8c3b710cb 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -171,7 +171,6 @@ typedef struct _mp_state_vm_t { #if MICROPY_PY_OS_DUPTERM mp_obj_t dupterm_objs[MICROPY_PY_OS_DUPTERM]; - mp_obj_t dupterm_arr_obj; #endif #if MICROPY_PY_LWIP_SLIP |