-
Notifications
You must be signed in to change notification settings - Fork 249
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
Converting values to lists using list comprehensions instead of list() #114
Comments
Sounds great, can you write a draft for this (have a look at a |
For sure, here's a draft of it: https://gist.github.com/AN3223/344d27279be6ee87e13c5fadf1af756d Apologies for the procrastination! |
The best for this example would be to use:
as |
I'm not sure about that:
FWIW, I would probably consider |
@tucked, let it got with the |
Yes, but I suspect after a certain point, as in my example, overhead is essentially negligible compared iteration over
I would call this premature optimization, but, you know, that's just, like, my opinion, man. |
@tucked, using |
Recently I've been using a lot of list comprehensions in Python. They're really useful. But I noticed that a lot of the time when I wanted to convert a generator or something into a list, I'd quickly write something like
[x for x in whatever]
and nothing else, when justlist(whatever)
would suffice. I suppose it's a readability thing?So in short:
Anti-pattern
Best practice
The text was updated successfully, but these errors were encountered: