diff --git a/py/objarray.c b/py/objarray.c index ac4e343d06..75bc671c16 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -191,7 +191,10 @@ static mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, // 1 arg, an integer: construct a blank bytearray of that length mp_uint_t len = mp_obj_get_int(args[0]); mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, len); + // If this config is set then the GC clears all memory, so we don't need to. + #if !MICROPY_GC_CONSERVATIVE_CLEAR memset(o->items, 0, len); + #endif return MP_OBJ_FROM_PTR(o); } else { // 1 arg: construct the bytearray from that