Skip to content

Commit 24c1000

Browse files
committed
objarray: Support array('O'), array of objects, as extension to CPython.
Might be useful at least for memoryview hacks.
1 parent 16b1f5e commit 24c1000

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

py/binary.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
141141
case 'd':
142142
return mp_obj_new_float(((double*)p)[index]);
143143
#endif
144+
// Extension to CPython: array of objects
145+
case 'O':
146+
return ((mp_obj_t*)p)[index];
144147
}
145148
return MP_OBJ_NEW_SMALL_INT(val);
146149
}
@@ -300,6 +303,10 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v
300303
((double*)p)[index] = mp_obj_get_float(val_in);
301304
break;
302305
#endif
306+
// Extension to CPython: array of objects
307+
case 'O':
308+
((mp_obj_t*)p)[index] = val_in;
309+
break;
303310
default:
304311
mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in));
305312
}

0 commit comments

Comments
 (0)