Commit 8f193175 authored by Damien George's avatar Damien George
Browse files

py: Remove useless implementations of NOT_EQUAL in binary_op's.

I'm pretty sure these are never reached, since NOT_EQUAL is always
converted into EQUAL in mp_binary_op.  No one should call
type.binary_op directly, they should always go through mp_binary_op
(or mp_obj_is_equal).
parent db049c2e
......@@ -106,8 +106,6 @@ mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return MP_BOOL(lhs_val >= rhs_val);
case MP_BINARY_OP_EQUAL:
return MP_BOOL(lhs_val == rhs_val);
case MP_BINARY_OP_NOT_EQUAL:
return MP_BOOL(lhs_val != rhs_val);
default:
// op not supported
......
......@@ -205,8 +205,6 @@ mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return MP_BOOL(cmp >= 0);
case MP_BINARY_OP_EQUAL:
return MP_BOOL(cmp == 0);
case MP_BINARY_OP_NOT_EQUAL:
return MP_BOOL(cmp != 0);
default:
return MP_OBJ_NULL;
......
......@@ -138,8 +138,6 @@ STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_MORE:
case MP_BINARY_OP_MORE_EQUAL:
return MP_BOOL(list_cmp_helper(op, lhs, rhs));
case MP_BINARY_OP_NOT_EQUAL:
return MP_BOOL(!list_cmp_helper(MP_BINARY_OP_EQUAL, lhs, rhs));
default:
// op not supported
......
......@@ -411,8 +411,6 @@ STATIC mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
return set_issubset(lhs, rhs);
case MP_BINARY_OP_MORE_EQUAL:
return set_issuperset(lhs, rhs);
case MP_BINARY_OP_NOT_EQUAL:
return MP_BOOL(set_equal(lhs, rhs) == mp_const_false);
case MP_BINARY_OP_IN:
{
mp_obj_set_t *o = lhs;
......
......@@ -137,8 +137,6 @@ mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_MORE:
case MP_BINARY_OP_MORE_EQUAL:
return MP_BOOL(tuple_cmp_helper(op, lhs, rhs));
case MP_BINARY_OP_NOT_EQUAL:
return MP_BOOL(!tuple_cmp_helper(MP_BINARY_OP_EQUAL, lhs, rhs));
default:
// op not supported
......
# test equality
print(None == None)
print(False == None)
print(False == False)
print(False == True)
print(() == ())
print(() == [])
print([] == [])
print(() == {})
print({} == ())
print(() == None)
print(() == False)
print(() == print)
print([] == None)
print([] == False)
print([] == print)
print({} == None)
print({} == False)
print({} == print)
print(1 == 1)
print(1 == 2)
print(1 == ())
print(1 == [])
print(1 == {})
print(1 == 'a')
print('a' == 'a')
print('a' == 'ab')
print('a' == 1)
print('a' == ())
# same as above but with !=
print(None != None)
print(False != None)
print(False != False)
print(False != True)
print(() != ())
print(() != [])
print([] != [])
print(() != {})
print({} != ())
print(() != None)
print(() != False)
print(() != print)
print([] != None)
print([] != False)
print([] != print)
print({} != None)
print({} != False)
print({} != print)
print(1 != 1)
print(1 != 2)
print(1 != ())
print(1 != [])
print(1 != {})
print(1 != 'a')
print('a' != 'a')
print('a' != 'ab')
print('a' != 1)
print('a' != ())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment