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

More efficient use of memory #3

Closed
impredicative opened this issue Jul 4, 2017 · 1 comment
Closed

More efficient use of memory #3

impredicative opened this issue Jul 4, 2017 · 1 comment
Assignees

Comments

@impredicative
Copy link

impredicative commented Jul 4, 2017

    urls = list(self.gen_urls(text))
    return urls if not only_unique else list(set(urls))

The above has an issue in that it needlessly creates the initial list even when a set is desired. This can be wasteful of memory. I didn't realize this before, but a better form is:

    urls = self.gen_urls(text)
    urls = set(urls) if only_unique else urls
    return list(urls)

The above form prevents creating a list of possibly non-unique URLs if only the unique ones are desired.

@lipoja
Copy link
Owner

lipoja commented Jul 4, 2017

Thank you, I fixed it in minor version 0.4.1

@lipoja lipoja closed this as completed Jul 4, 2017
@lipoja lipoja self-assigned this Jul 4, 2017
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

No branches or pull requests

2 participants