diff options
author | David Lechner <david@pybricks.com> | 2022-12-27 16:30:05 -0600 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-05-19 12:04:44 +1000 |
commit | eaccaa36771f784dfb458b8ba3591f11513824e6 (patch) | |
tree | 7ecce76ccff90c6b0b4093e830edc7aff0c7d892 /py/runtime.c | |
parent | 53cb073571196d2ba7174706d5d784e42e5430cf (diff) |
py/obj: Remove mp_generic_unary_op().
Since converting to variable sized slots in mp_obj_type_t, we can now
reduce the code size a bit by removing mp_generic_unary_op() and the
corresponding slots where it is used. Instead we just implement the
generic `__hash__` operation in the runtime.
Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c index 3c7c0350c..47e094763 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -314,6 +314,9 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) { if (result != MP_OBJ_NULL) { return result; } + } else if (op == MP_UNARY_OP_HASH) { + // Type doesn't have unary_op so use hash of object instance. + return MP_OBJ_NEW_SMALL_INT((mp_uint_t)arg); } if (op == MP_UNARY_OP_BOOL) { // Type doesn't have unary_op (or didn't handle MP_UNARY_OP_BOOL), |