Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-24700: Add a fast path for comparing array.array of equal type #3009

Merged
merged 1 commit into from
Aug 17, 2017

Conversation

adrian17
Copy link
Contributor

@adrian17 adrian17 commented Aug 6, 2017

@@ -685,14 +735,17 @@ array_richcompare(PyObject *v, PyObject *w, int op)

if (k) {
/* No more items to compare -- compare sizes */
equal_except_size: ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It confused me that this can be jumped into even when sizes are equal. I would suggest renaming equal_except_size to something else. Perhaps compare_sizes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this change was reversed.

@pitrou
Copy link
Member

pitrou commented Aug 8, 2017

This lacks a NEWS entry as produced by the blurb utility. Could you add one?

@pitrou
Copy link
Member

pitrou commented Aug 12, 2017

One thing: how does this fare on arrays of NaNs? Currently we have:

>>> a = array.array("d", [float('nan')])
>>> b = array.array("d", [float('nan')])
>>> a == b
False
>>> a > b
False
>>> a < b
False

@adrian17
Copy link
Contributor Author

Right, didn't check to handle it. I added a test case for NaN - even if the optimization doesn't get merged, the test case would still be nice to have.

I realized I also missed the PyFPE_START_PROTECT macros. All in all, properly handling floats would either complicate the code a lot, or make the fast path slower in general, so I decided I'd rather just disable the fast path for floats.

@pitrou
Copy link
Member

pitrou commented Aug 12, 2017

All in all, properly handling floats would either complicate the code a lot, or make the fast path slower in general, so I decided I'd rather just disable the fast path for floats.

Fair enough. Someone else can re-add a fast path for floats if they want to.

@pitrou pitrou merged commit 7c17e23 into python:master Aug 17, 2017
@adrian17 adrian17 deleted the fast-path-v4 branch August 17, 2017 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants