Skip to content

Conversation

sayandipdutta
Copy link

@sayandipdutta sayandipdutta commented Feb 1, 2022

closes #62
closes #63

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.
  • More pythonic.

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.
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.
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.

Unnecessarily loading file contents of pairs.txt into memory lfw_eval.py Same index counter in lfw_eval.py at line 90 and line 106
1 participant