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

Avoid calling render_sql twice #55

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Conversation

lonvia
Copy link
Contributor

@lonvia lonvia commented Nov 25, 2024

If you have a generator of the form

[f(x) for x in foo if f(x)]

then Python has to call function f() twice for every element because it cannot know if f() has side-effects. What you want to do here instead apply a filter to the results.

NB: do you really want to eliminate duplicates here? If not, then it would be faster to return a list instead of a set.

@pnorman
Copy link
Owner

pnorman commented Nov 25, 2024

I think eliminating duplicates is actually a bug, although not one that is possible to hit in practice. A list would be better.

@lonvia
Copy link
Contributor Author

lonvia commented Nov 25, 2024

Changed set to list.

@pnorman pnorman merged commit 24354d6 into pnorman:main Nov 25, 2024
6 checks passed
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.

2 participants