Browse Source

py/runtime: Optimise to not create temp float for int to power negative.

pull/4698/head
Damien George 6 years ago
parent
commit
1754c71f45
  1. 3
      py/runtime.c

3
py/runtime.c

@ -456,8 +456,7 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_INPLACE_POWER: case MP_BINARY_OP_INPLACE_POWER:
if (rhs_val < 0) { if (rhs_val < 0) {
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
lhs = mp_obj_new_float(lhs_val); return mp_obj_float_binary_op(op, lhs_val, rhs);
goto generic_binary_op;
#else #else
mp_raise_ValueError("negative power with no float support"); mp_raise_ValueError("negative power with no float support");
#endif #endif

Loading…
Cancel
Save