Mar-11-2018, 11:54 PM
(Mar-10-2018, 08:56 PM)mepyyeti Wrote: I hear lambda is significantly faster than list comp? So it is easier on resources.Not True in most cases are list comp faster.
λ python -m timeit "list(map(lambda x: x+10, [1,2,3]))" 1000000 loops, best of 3: 1.2 usec per loop λ python -m timeit "[x+10 for x in [1,2,3]]" 1000000 loops, best of 3: 0.463 usec per loopFunctional style can have advantages if done right,not talking about speed but less side effect.
Can go down a rabbit hole if talk to people who love functional programming
![Shifty Shifty](https://python-forum.io/images/smilies/eusa_shifty.gif)
Python is of course not a functional language,but has support for a functional programming style.
List comp is looked upon as more Pythonic.
(Mar-11-2018, 09:17 PM)mepyyeti Wrote: Why would you press space 4x?No one press 4-space,Tab is set to move 4-space in almost all Python editors.
If not configure Tab to move 4-space.