Using map() in Python #shorts

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Python map returns a map object not a list. And that why we send the result to list.

КонстантинСавин-кя
Автор

Map is seriously insane. I was optimizing a code that would extract dictionary in a dataframe column that was worth a few tb and the old implementation used list comprension, loops and multiprocessing to do that. It took abt 10 minutes to get 150000 records. With map and iterators my code did the same thing in 40s

TojiFushigoroWasTaken
Автор

Such an easy to understand and memorable explanation ☺️

warishakhan
Автор

This kinda make sense instantly for JavaScript devs XD

TaurenWarriorKrieg
Автор

could have just used a list comprehension
result = [number * 2 for number in numbers]

danielschmider
Автор

Python does not need map because it has something better: list comprehensions!
result = [double(a) for a in numbers]

its more pythonic, better readable and faster

raphmvids
Автор

Instead of this, we can do from this map!

krishnagaderi
Автор

In terms of performance, which is better, Map or For?

fqty
Автор

Ok. My very first question is, why not just pass the numbers list into the function and then save the result in a variable? I’m trying to see the benefit but am coming up short.

QuintinMassey
Автор

omg, no ;-;
do "[n * 2 for n in numbers]" instead

brunogehlen
Автор

Could you not have just run the function with the list as a parameter?

IAmJuniorB
Автор

Advice from a python dev: don't use map. It is unintuitive to read and leads to really terse code. List comprehension for simple operations and a for loop for more complex things.

Wineblood
Автор

Pin, if i trick you.


...Read more

elonfc
Автор

I like to MemoryMap big Gig files using GnuCOBOL on Linux. MMAP

justwanderin
Автор

I am learning intermediate python and was thinking real use of map function yesterday and YouTube suggests me this short today... Freecodecamp peeps u deserve one treat from me when i get into a big IT product based company

kamleshkumarsingh