Hacker News new | past | comments | ask | show | jobs | submit login

Python 3 at least changes the semantics of map and filter so that they are generators.

Lazy sequences are the sort of thing that you don't care about until you need to process a ten-million-line file (or whatever) and suddenly find that your program is slowing down for pointless memory allocations up-front -- then they become unbelievably important.




Yes, you are absolutely correct. In our production code, which is currently running 2.7, we make extensive use of the itertools versions of those functions (imap, ifilter, etc.) for this reason. The itertools functions behave exactly like the Python 3 builtins, as iterators. The memory footprint is minimal, and they are just overall faster.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: