statement: [x**x for x in range(0,100)] time taken: 45.45980668100037 seconds statement: Before running timer def func(x): ... return x**x li = [x for x in range(0,100)] The statement below was measured list(map(func, li)) time taken: 50.2515873479997 Conclusion: List Comprehension is fast
if you want for exampe to grab the element that are a string from an array I think it is better to use the filter function because it returns the array with the elements that are a string BUT with the map function it returns an array with true and false only
Great short explanation. One thing, when you say map takes in two parameters, function and a list, do you mean only a list and not any other iterables such as tuples, sets, generators, etc. ?
hey! thank you for the videos!!! I am also going through corresponding notes on your site and have a question. " numList.append(f1(nums))" should't it be " newList.append(f1(item))" otherwise it doesn't work
It has been two or more years since you made this video, so you may not be reading this anymore - but: I suggest that you find a small set of viewers to act as 'reviewer/editors' of your videos prior to release. Your content is good but then there is some glossing over and omission. For instance: in this video near the end you briefly mention the func2 idea. Now I think I get the reasoning - but you did not complete the example. The omission will leave some with a ?huh? stuck in the head.
awesome, finally someone who can explain quickly and easily
The map() explanation with the if statement is just so useful. Thx man
thnx you,,, i was looking for something like this since the majority of videos are focucing in teaching the basics.
same
I required this for competitive programming
No one needs to tell you how good your channel is. The amount of dislikes you got on this video already shows everyone likes you. Good job buddy.
Also the map function is magnitudes faster than the for loop. probably the more important reason to be using it instead of a loop
is it faster than using list comprehension too?
For the example I used yes, slightly faster. But your mileage may vary. Best to try it yourself
loving this series!
Great video and explanation! it's really sad for me that your channel is so small. your content is good and the upload rate is high!
Tomer Shechner not for me tho...
i like your method of teaching
thanks sir
the way i want to learn
Thanks Tim
Which one runs faster? List comprehension or map function?
statement: [x**x for x in range(0,100)]
time taken: 45.45980668100037 seconds
statement:
Before running timer
def func(x):
... return x**x
li = [x for x in range(0,100)]
The statement below was measured
list(map(func, li))
time taken: 50.2515873479997
Conclusion: List Comprehension is fast
@@Shahzaib786ik Thanks for the info man.
@@Shahzaib786ik wtf that doesnt take 45 seconds to execute. What are you running this on? Your calculator?
Map function: Wall time: 4.29 µs
List comprehension: Wall time: 6.91 µs
@@adrianmh i put the number wrong. I used big value. sorry
if you want for exampe to grab the element that are a string from an array I think it is better to use the filter function
because it returns the array with the elements that are a string BUT with the map function it returns an array with true and false only
Great tim
Thanks for this amazing video...
Your Channel is Great!
Good explanations skills!
You deserve an audience.
Have you optimized your content for youtube search?
Great short explanation. One thing, when you say map takes in two parameters, function and a list, do you mean only a list and not any other iterables such as tuples, sets, generators, etc. ?
From my understanding it takes a function and an iterable
another banger
It seems that the map function can't be used on numpy arrays, right?
hey! thank you for the videos!!! I am also going through corresponding notes on your site and have a question. " numList.append(f1(nums))" should't it be " newList.append(f1(item))" otherwise it doesn't work
seems that using list comprehensions will be simpler if u want to get a list
Question: Shadows name 'x' from outer scope
print(list(map(func.li)))
Does it means new list = the expression of the func2
thank you!
wtf...
i have a doubt when i use list word in map function in jupyter notebook output is coming that list is not capable. is there any reason for it?
does it work with ndarrays ?
How could there be only 8 comments......
R there only 8 intermidiate programmers in the world...
:O
Python 2 in 2018??
How did 3 become 27 when it was applied to the function? 2:52
actually ignore this LOL, silly question
🤡
@@ethanmallard5942 happens to the best of us
func2 in func(x) is not working
1:48
Why does it say 'L' in the last item of the new list
to show that the integer is "Large"
li = [x**x for x in range(1,11)]
print(li) also works
is this called list comprehension?
@@4TH4RV yes that's it
So you mean every single thing is possible in python?
no.
literally vaush
class
Not Activated Windows is a big red flag, but I watched your tutorial regardless
It has been two or more years since you made this video, so you may not be reading this anymore - but:
I suggest that you find a small set of viewers to act as 'reviewer/editors' of your videos prior to release. Your content is good but then there is some glossing over and omission. For instance: in this video near the end you briefly mention the func2 idea. Now I think I get the reasoning - but you did not complete the example. The omission will leave some with a ?huh? stuck in the head.
Activate windows!