gh-144995: Optimize memoryview == memoryview#144996
gh-144995: Optimize memoryview == memoryview#144996vstinner wants to merge 4 commits intopython:mainfrom
Conversation
|
Results of the benchmark from the issue: memoryview comparison complexity is no longer O(n) but O(1): values are no longer compared. |
Objects/memoryobject.c
Outdated
| } | ||
|
|
||
| static int | ||
| is_float_format(const char *format) |
There was a problem hiding this comment.
Does this cover the complex types?
import numpy as np
a = np.array([1+2j, 3+4j, float('nan')], dtype=np.complex128)
mv = memoryview(a)
mv == mv # False
There was a problem hiding this comment.
This memory format is Zd. Oh, my change doesn't work for this memoryview. I should replace the blocklist with an allowlist. I'm not a memoryview/buffer expert. I didn't know that 3rd party projects can have their own format.
|
@eendebakpt: I updated the PR to allow formats known to be safe for pointer comparison (integer types), instead of blocking formats known to use floats. I excluded the format |
I think adding the |
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.