2 ms·
The missing slide: profiling. I love functional programming. Nonetheless, I strongly believe in using the natural idioms of your language: they are more widely
by Locke1689 13y ago
The missing slide: profiling.
I love functional programming. Nonetheless, I strongly believe in using the natural idioms of your language: they are more widely used, more widely optimized, and more often thought about.
I think you would find that the functional style is not idiomatic in Python most of the time. This can hurt readability, performance, and interoperability.
Overall, I would encourage people to do what is natural -- it is often also what's correct. For example, Python generators expressions are lazy sequence semantic constructions and are both functional in semantics and better than the equivalent map/reduce semantics.
- matchu 13y agoThe itertools library offers imap, ifilter, etc. for big cases, but I tend to agree that generators read better and are shorter surprisingly often.
- b0rsuk 13y agoGood points. Python lists are surprisingly slightly faster than tuples (which are immutable). That's because lists are extremely common, and more effort went into optimizing them.