I just have a quick question. What version of python are you using? The reason I am asking is due to our own experiments with map vs list comprehensions differ based on python2 and python3.
The timing in the example above are wrong. The map example generates a new function at every loop, while the list comprehension just multiplies the result.
If you define a function outside or use one already available, map should actually be slightly faster (without taking into account that map is lazy, so if you don't need that value you'll have the best performance possible :))
Log in to continue
We're a place where coders share, stay up-to-date and grow their careers.
I just have a quick question. What version of python are you using? The reason I am asking is due to our own experiments with map vs list comprehensions differ based on python2 and python3.
Thanks
The timing in the example above are wrong. The map example generates a new function at every loop, while the list comprehension just multiplies the result.
If you define a function outside or use one already available, map should actually be slightly faster (without taking into account that map is lazy, so if you don't need that value you'll have the best performance possible :))