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

Using map() or filter() where list comprehension is possible #132

Open
drsasa opened this issue Jul 29, 2019 · 1 comment
Open

Using map() or filter() where list comprehension is possible #132

drsasa opened this issue Jul 29, 2019 · 1 comment

Comments

@drsasa
Copy link

drsasa commented Jul 29, 2019

Generally this section is misleading.

I understand what writer wanted to say but its not correct.

map() returns an iterator not list. Therefore in text on few places is mentioned that map()
returns list.

Therefore use case for map over list comprehension is let's say bit different and with map
can be more memory efficient.

I'm just pointing out, so that section can be bit adjusted, but rest standing.

@dmtucker
Copy link

dmtucker commented Aug 1, 2019

Generator expressions are lazy and (AFAIK) accepted anywhere a map object would be:

>>> ' '.join(map(str, range(5))) == ' '.join(str(i) for i in range(5))
True

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