diff options
| author | Damien George <damien@micropython.org> | 2023-10-13 15:27:05 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-10-13 15:29:09 +1100 |
| commit | 516385c4ccbb1f7fa9dbd37a44ed8ae33dcf1942 (patch) | |
| tree | 393190e62acf5e41c3154987e7ca2985b523b03b /py | |
| parent | 66c62353ce35d72d7322740ad88f3c4986f31e64 (diff) | |
py/objboundmeth: Optimise check for types in binary_op.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py')
| -rw-r--r-- | py/objboundmeth.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/py/objboundmeth.c b/py/objboundmeth.c index 10f52016c..b0be810c5 100644 --- a/py/objboundmeth.c +++ b/py/objboundmeth.c @@ -94,7 +94,10 @@ STATIC mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } STATIC mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - if (!mp_obj_is_type(rhs_in, &mp_type_bound_meth) || op != MP_BINARY_OP_EQUAL) { + // The MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE flag is clear for this type, so if this + // function is called with MP_BINARY_OP_EQUAL then lhs_in and rhs_in must have the + // same type, which is mp_type_bound_meth. + if (op != MP_BINARY_OP_EQUAL) { return MP_OBJ_NULL; // op not supported } mp_obj_bound_meth_t *lhs = MP_OBJ_TO_PTR(lhs_in); |
