This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Equality operations between lists and arrays
Type: enhancement Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Ahmed Amr, rhettinger, terry.reedy
Priority: normal Keywords:

Created on 2020-04-29 02:52 by Ahmed Amr, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
equality_between_arrays_and_lists.py Ahmed Amr, 2020-04-29 02:52 Python 3 Code showing the above behaviour
Messages (3)
msg367615 - (view) Author: Ahmed Amr (Ahmed Amr) * Date: 2020-04-29 02:52
Hi, I was thinking if we could add equality between array and list to work out of the box on the supported datatypes by arrays.

Currently, comparing a list and an array with the same contents returns False.

Also, creating an array of floats from a listA, then turning that array into a listB, returns different contents between listA and listB.

It's somehow counter-intuitive for me as even if the underlying implementations are different between array and list, they can be viewed as an array data structure but with different restrictions/implementations, along with that, arrays compare to each other correctly, and lists compare to each other correctly.

based on that, switching some lists to arrays in a python codebase may break some equality conditions within that code between lists and arrays
msg367900 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-05-01 23:30
This is not clearly a good idea.  Lists and tuples with same contents do not compare equal, although set and frozenset do.  I suggest that you post this idea to python-ideas list.
msg367911 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-05-02 03:52
I concur with Terry that this would need to be taken to python-ideas.
History
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84613
2020-05-02 03:52:58rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg367911

stage: resolved
2020-05-01 23:30:16terry.reedysetnosy: + rhettinger, terry.reedy

messages: + msg367900
versions: - Python 3.5, Python 3.6, Python 3.7, Python 3.8
2020-04-29 02:52:17Ahmed Amrcreate