On Sat, 2 May 2020 at 15:06, Ahmed Amr <ahmedam...@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 _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3L7URUZIBQIXNZOBXS77ROUHGJJKLG6J/ Code of Conduct: http://python.org/psf/codeofconduct/