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

Performance Tweaks, Iterators, and Lazy Evaluations #308

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

PyWoody
Copy link

@PyWoody PyWoody commented Apr 22, 2024

A new function, dejavu.logic.decoder.find_files_g, has been created as an iterator replacement for find_files in the same file. This allows the updated Dejavu.fingerprint_directory method to utilize the concurrent.futures.ProcessPoolExecutor in conjunction with the concurrent.futures.as_completed function to submit files to be processed as they are yielded for immediate processing. Once all of the files have been submitted to the executor for processing, their respective results will be iterated over in as_completed...as they are completed.

These two modifications will allow considerable speed improvements over the existing methods. If anyone knows of where to find a large number of Creative Common openly licensed audio files to download and test on, I would be glad to post comparison results. I tried finding some today but every website was either broken, required creating accounts, or was so extensively rate-limited to be near useless.

Other minor improvements are

  • Adding placeholder songs and songhashes_set in the __init__ of Dejavu to take advantage of __init__'s special dict
  • Changing counts and songs_matches in Dejavu.align_matches to generator comprehensions
  • Adding song_hash directly to self.songhashes_set instead of creating the variable first. Saves a lookup per iteration
  • Waiting to call Dejavu.__load_fingerprinted_audio_hashes() until after all files have been processed
  • Changing both channels in dejavu.logic.decoder.read to use list comprehensions

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.

1 participant