py: Remove mp_load_const_bytes and instead load precreated bytes object.
Previous to this patch each time a bytes object was referenced a new
instance (with the same data) was created. With this patch a single
bytes object is created in the compiler and is loaded directly at execute
time as a true constant (similar to loading bignum and float objects).
This saves on allocating RAM and means that bytes objects can now be
used when the memory manager is locked (eg in interrupts).
The MP_BC_LOAD_CONST_BYTES bytecode was removed as part of this.
Generated bytecode is slightly larger due to storing a pointer to the
bytes object instead of the qstr identifier.
Code size is reduced by about 60 bytes on Thumb2 architectures.
diff --git a/py/showbc.c b/py/showbc.c
index e08140e..2da8d3f 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -155,11 +155,6 @@
break;
}
- case MP_BC_LOAD_CONST_BYTES:
- DECODE_QSTR;
- printf("LOAD_CONST_BYTES %s", qstr_str(qst));
- break;
-
case MP_BC_LOAD_CONST_STRING:
DECODE_QSTR;
printf("LOAD_CONST_STRING '%s'", qstr_str(qst));
@@ -168,7 +163,7 @@
case MP_BC_LOAD_CONST_OBJ:
DECODE_PTR;
printf("LOAD_CONST_OBJ %p=", (void*)unum);
- mp_obj_print((mp_obj_t)unum, PRINT_REPR);
+ mp_obj_print_helper(&mp_plat_print, (mp_obj_t)unum, PRINT_REPR);
break;
case MP_BC_LOAD_NULL: