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

Add tp_richcompare handler for Imaging_Type/ImagingCore #7260

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Yay295
Copy link
Contributor

@Yay295 Yay295 commented Jul 5, 2023

Imaging_Type/ImagingCore is exposed by Image.getdata(), so this allows you to properly compare the result of that method without it being an identity comparison. This should also speed up comparison between Image objects, because now the comparison is done in C instead of passing the data back to Python for it to be compared.

Tests/test_lib_image.py Outdated Show resolved Hide resolved
@radarhere
Copy link
Member

Valgrind is currently failing - https://github.com/python-pillow/Pillow/actions/runs/5460694184/jobs/9937936242?pr=7260

Also, I went to test the speed of image equality with this, radarhere@98e02aa... and found https://github.com/radarhere/Pillow/actions/runs/5461893489/jobs/9940492884#step:8:4787

Fatal Python error: bool_dealloc: deallocating True or False: bug likely caused by a refcount error in a C extension

@Yay295
Copy link
Contributor Author

Yay295 commented Jul 5, 2023

oops, Py_NewRef wasn't added until Python 3.10.

Tests/test_lib_image.py Outdated Show resolved Hide resolved
Tests/test_lib_image.py Show resolved Hide resolved
src/_imaging.c Outdated Show resolved Hide resolved
Tests/test_lib_image.py Outdated Show resolved Hide resolved
Tests/test_lib_image.py Outdated Show resolved Hide resolved
Tests/test_lib_image.py Outdated Show resolved Hide resolved
Py_True and Py_False were only made immortal in Python 3.12, so we have to properly increment their refcount for versions before that.
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.

None yet

3 participants