On Sat, 2 May 2020 at 15:06, Ahmed Amr <ahmedamron@gmail.com> wrote:
I'd like to take your opinion on modifying some of the indexed collections like tuples, lists, arrays to evaluate its equality to True when having the same items in the same indexes. Currently, when comparing a list of items to an array of the same items for equality (==) it returns False, I'm thinking that it would make sense to return True in that context, as we're comparing item values and we have the same way of indexing both collections, so we can compare item values.
So what do you think about applying such behavior on collections that can be indexed the same way such as tuples, lists, and arrays?
Example: (Current)
import array tuple_ = (1.1, 2.2, 3.3) list_ = [1.1, 2.2, 3.3] array_ = array.array('f', [1.1, 2.2, 3.3])
# all of the following prints False. print(tuple_ == list_) print(tuple_ == array_) print(array_ == list_)
import numpy as np np.array_equal((1.1, 1.2, 1.3), [1.1, 1.2, 1.3]) True