diff --git a/py/obj.h b/py/obj.h
index 4e2c95683569843811636c9f78391a77ca693a90..0f99e5dfc85e8b0a62ba06f86befd484ce2be71c 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -349,6 +349,7 @@ extern const mp_obj_type_t zip_type;
 // array
 extern const mp_obj_type_t array_type;
 uint mp_obj_array_len(mp_obj_t self_in);
+mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items);
 
 // functions
 typedef struct _mp_obj_fun_native_t { // need this so we can define const objects (to go in ROM)
diff --git a/py/objarray.c b/py/objarray.c
index 9911e89df92d3a3ec314ab7883a84e68959a3f78..42dbfcda055197171aa889666f2bca0d3d4dd102 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -271,6 +271,17 @@ mp_obj_t mp_obj_new_bytearray(uint n, void *items) {
     return o;
 }
 
+// Create bytearray which references specified memory area
+mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items) {
+    mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
+    o->base.type = &array_type;
+    o->typecode = BYTEARRAY_TYPECODE;
+    o->free = 0;
+    o->len = n;
+    o->items = items;
+    return o;
+}
+
 /******************************************************************************/
 /* array iterator                                                              */