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.
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 :))