Avoid explicit calls to select.select()#98
Open
jukuisma wants to merge 1 commit intosylikc:masterfrom
Open
Conversation
Use higher level `selectors` module instead: https://docs.python.org/3/library/selectors.html. Selectors uses the most efficient implementation available on the current platform. On Linux, it defaults to using: ``` $ python3 -c "import selectors; print(selectors.DefaultSelector())" <selectors.EpollSelector object at 0x7a6a66f02120> ```
35a2e60 to
c340c3f
Compare
Author
|
|
Author
vagrant@almalinux:~/test$ cat benchmark.py
import exiftool
images = [ f"images/{i}" for i in range(512)]
with exiftool.ExifToolHelper() as et:
print(et.get_metadata(images))
for i in range(512):
print(exiftool.ExifToolHelper().get_metadata(f"images/{i}"))Old: vagrant@almalinux:~/test$ rpm -q python3-pyexiftool
python3-pyexiftool-0.5.6-1.el9.noarch
vagrant@almalinux:~/test$ python3 benchmark.py | md5sum
8cb4cc1e001e1abcfe6a4b4bae714288 -
vagrant@almalinux:~/test$ time python3 benchmark.py > /dev/null
real 0m48.851s
user 0m42.612s
sys 0m6.483sNew: vagrant@almalinux:~/test$ rpm -q python3-pyexiftool
python3-pyexiftool-0.5.6-2.el9.noarch
vagrant@almalinux:~/test$ python3 benchmark.py | md5sum
8cb4cc1e001e1abcfe6a4b4bae714288 -
vagrant@almalinux:~/test$ time python3 benchmark.py > /dev/null
real 0m47.134s
user 0m41.186s
sys 0m6.156sAnd just: To get some rounds in, old: New: I'm seeing next to no difference between the two solutions on my alma9 VM. Testing larger images could be useful, but all our test images are small not to bloat the git repo. These 512 images are all: https://github.com/Digital-Preservation-Finland/file-scraper/blob/master/tests/data/image_jpeg/valid_2.2.1_exif_metadata.jpg. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use higher level
selectorsmodule instead:https://docs.python.org/3/library/selectors.html.
Selectors uses the most efficient implementation available on the current platform. On Linux, it defaults to using:
Fixes: #97