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

Seek relative to current position #8709

Merged
merged 1 commit into from
Jan 31, 2025
Merged

Conversation

radarhere
Copy link
Member

To restore the previous position after a read,
seek relative to the current position,
rather than using tell() and then seeking relative to the start of the file.

@hugovk
Copy link
Member

hugovk commented Jan 31, 2025

The PR is marginally faster than main:

main

python -m timeit -s 'from PIL import Image' 'Image.open("Tests/images/gfs.t06z.rassda.tm00.bufr_d")'
20000 loops, best of 5: 13 usec per loop

PR

python -m timeit -s 'from PIL import Image' 'Image.open("Tests/images/gfs.t06z.rassda.tm00.bufr_d")'
20000 loops, best of 5: 12.7 usec per loop

@hugovk hugovk merged commit 793e1fc into python-pillow:main Jan 31, 2025
52 checks passed
@radarhere radarhere deleted the seek branch January 31, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants