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

Unnecessarily loading file contents of pairs.txt into memory lfw_eval.py #63

Open
sayandipdutta opened this issue Feb 1, 2022 · 0 comments · May be fixed by #64
Open

Unnecessarily loading file contents of pairs.txt into memory lfw_eval.py #63

sayandipdutta opened this issue Feb 1, 2022 · 0 comments · May be fixed by #64

Comments

@sayandipdutta
Copy link

In lfw_eval.py, the contents of pairs.txt is being loaded into memory, even though it is not used for anything other than iterating over the lines. It will be easier and more memory efficient to iterate over the file object itself.

with open('data/pairs.txt') as f:
    pairs_lines = f.readlines()[1:]

Which will also avoid the __getitem__ call in line 91, making the code more efficient.

for i in range(6000):
    p = pairs_lines[i].replace('\n','').split('\t')
@sayandipdutta sayandipdutta linked a pull request Feb 1, 2022 that will close this issue
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 a pull request may close this issue.

1 participant