[issue24700] array compare is hideously slow

lou1306 report at bugs.python.org
Mon Feb 27 13:35:02 EST 2017


lou1306 added the comment:

I noticed the issue is still there in Python 3.6.
But I can't see why array subclasses should be the reason for this implementation.
By looking at getarrayitem, it looks like __getitem__ does not play any role in how the elements are accessed.
Consider the attached example, where SubclassedArray.__getitem__ is overridden to always return 0: nonetheless, equality checks with an array.array containing the same elements always succeed.

> For cases where the signedness and element size are identical, it's trivial to acquire readonly buffers for both arrays and directly compare the memory

I would argue that _integerness_ sholud also be identical: otherwise
array("l", range(10)) == array("f", range(10))
would evaluate to False, while it is True in the current implementation.

----------
nosy: +Luca Di Stefano
Added file: http://bugs.python.org/file46675/subclass_test.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24700>
_______________________________________


More information about the Python-bugs-list mailing list