Skip to content

Commit

Permalink
objarray: Support array('O'), array of objects, as extension to CPython.
Browse files Browse the repository at this point in the history
Might be useful at least for memoryview hacks.
  • Loading branch information
pfalcon committed Mar 5, 2015
1 parent 16b1f5e commit 24c1000
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions py/binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
case 'd':
return mp_obj_new_float(((double*)p)[index]);
#endif
// Extension to CPython: array of objects
case 'O':
return ((mp_obj_t*)p)[index];
}
return MP_OBJ_NEW_SMALL_INT(val);
}
Expand Down Expand Up @@ -300,6 +303,10 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v
((double*)p)[index] = mp_obj_get_float(val_in);
break;
#endif
// Extension to CPython: array of objects
case 'O':
((mp_obj_t*)p)[index] = val_in;
break;
default:
mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in));
}
Expand Down

0 comments on commit 24c1000

Please sign in to comment.