diff options
author | Damien George <damien.p.george@gmail.com> | 2016-09-16 12:30:09 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-09-16 12:30:09 +1000 |
commit | f84b3416187c8144fd92e52d97a655a133d725b2 (patch) | |
tree | 907397fead6c4dba3eb12b5f4fbb6c7b08fbe467 /py/objnone.c | |
parent | 3fea1f014c949a1268baad175b767177552e4b00 (diff) |
py/objnone: Remove unnecessary handling of MP_UNARY_OP_BOOL.
bool(None) has a fast path in mp_obj_is_true so doesn't need to be
handled in none_unary_op. The only caveat is that subclassing may
bypass the mp_obj_is_true function, but actually you aren't allowed to
subclass classes that have singleton instances like NoneType (see
https://mail.python.org/pipermail/python-dev/2002-March/020822.html for
reference on this point).
Diffstat (limited to 'py/objnone.c')
-rw-r--r-- | py/objnone.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objnone.c b/py/objnone.c index 69eab03fe..74c02e4d2 100644 --- a/py/objnone.c +++ b/py/objnone.c @@ -46,7 +46,7 @@ STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ STATIC mp_obj_t none_unary_op(mp_uint_t op, mp_obj_t o_in) { (void)o_in; switch (op) { - case MP_UNARY_OP_BOOL: return mp_const_false; + // MP_UNARY_OP_BOOL is handled by a fast-path in mp_obj_is_true case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in); default: return MP_OBJ_NULL; // op not supported } |