-
Notifications
You must be signed in to change notification settings - Fork 23
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
Avoid explicit calls to select.select() #98
base: master
Are you sure you want to change the base?
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
|
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.483s New: 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.156s And 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. |
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:
Fixes: #97