diff --git a/py/obj.h b/py/obj.h
index 95a94836e71b4c659c8d560bf60f27d6711553ab..8e4083920abb2407a99e2a7d4dd9aeff37e3baf7 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -451,16 +451,6 @@ typedef struct _mp_buffer_p_t {
 bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
 void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
 
-// Stream protocol
-typedef struct _mp_stream_p_t {
-    // On error, functions should return MP_STREAM_ERROR and fill in *errcode (values
-    // are implementation-dependent, but will be exposed to user, e.g. via exception).
-    mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode);
-    mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode);
-    mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode);
-    mp_uint_t is_text : 1; // default is bytes, set this for text stream
-} mp_stream_p_t;
-
 struct _mp_obj_type_t {
     // A type is an object so must start with this entry, which points to mp_type_type.
     mp_obj_base_t base;
diff --git a/py/stream.h b/py/stream.h
index a1d1c4f8af73d1cfb77d6f122b8523305de1803b..3dec49a2e99567f0d3dc219eba756efcdc30eb5d 100644
--- a/py/stream.h
+++ b/py/stream.h
@@ -62,6 +62,16 @@ struct mp_stream_seek_t {
 #define MP_SEEK_CUR (1)
 #define MP_SEEK_END (2)
 
+// Stream protocol
+typedef struct _mp_stream_p_t {
+    // On error, functions should return MP_STREAM_ERROR and fill in *errcode (values
+    // are implementation-dependent, but will be exposed to user, e.g. via exception).
+    mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode);
+    mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode);
+    mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode);
+    mp_uint_t is_text : 1; // default is bytes, set this for text stream
+} mp_stream_p_t;
+
 MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj);
 MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read1_obj);
 MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_readinto_obj);