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

Improved logic for iterating over 'pairs.txt' #64

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

Commits on Feb 1, 2022

  1. Improved logic for iterating over 'pairs.txt'

    Instead of loading the entire file into the memory, use the iterator
    object natively provided by the file object returned by the open
    function.
    
    - This saves memory.
    - Avoid __getitem__ call, improve performance.
    sayandipdutta committed Feb 1, 2022
    Configuration menu
    Copy the full SHA
    b3db44b View commit details
    Browse the repository at this point in the history
  2. Change inner loop to use enumerate

    The inner loop used `range(len(imglist))`, this iterates over the entire
    length twice. Using `enumerate` saves one complete iteration.
    
    Furthermore, inside the inner loop `__getitem__` and `__setitem__` were
    being called twice in each iteration. Reduces `__getitem__` calls to 0,
    as it is already being taken care by for loop, and reduced `__setitem__`
    to 1.
    sayandipdutta committed Feb 1, 2022
    Configuration menu
    Copy the full SHA
    3a4c230 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    762c458 View commit details
    Browse the repository at this point in the history