Unlocking your CPU cores in Python (multiprocessing)

  Переглядів 287,329

mCoding

mCoding

Рік тому

How to use all your CPU cores in Python?
Due to the Global Interpreter Lock (GIL) in Python, threads don't really get much use of your CPU cores. Instead, use multiprocessing! Process pools are beginner-friendly but also quite performant in many situations. Don't fall into some of the many traps of multiprocessing though, this video will guide you though it.
― mCoding with James Murphy (mcoding.io)
Source code: github.com/mCodingLLC/VideosS...
SUPPORT ME ⭐
---------------------------------------------------
Patreon: / mcoding
Paypal: www.paypal.com/donate/?hosted...
Other donations: mcoding.io/donate
Top patrons and donors: Jameson, Laura M, Vahnekie, Dragos C, Matt R, Casey G, Johan A, John Martin, Jason F, Mutual Information, Neel R
BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord: / discord
Github: github.com/mCodingLLC/
Reddit: / mcoding
Facebook: / james.mcoding
MUSIC
---------------------------------------------------
It's a sine wave. You can't copyright a pure sine wave right?

КОМЕНТАРІ: 227
@tdug1991
@tdug1991 Рік тому
It's also worth noting that smaller chunk sizes may be better for unpredictably distributed job times, as one runner may randomly grab many expensive jobs, and lock the pool when the rest of the processes finish. Great video, as always!
@unusedTV
@unusedTV Рік тому
Your video is about two years late for me! I was working on a heat transfer simulation in Python where we had to compare hundreds of different input configurations. I knew about the GIL and multiprocessing in general outside of Python, but had to figure out myself how to get it to work. Eventually I settled on a multiprocessing pool and it worked wonders, because now we could run 32 simulations in parallel (Threadripper 1950x). Quick caveat that I don't hear you mention: a lot of processors have hyperthreading/SMT (intel/amd respectively), showing double the amount of cores in the task manager. In our case we found that spawning a process for each physical core provided better results than using all logical cores.
@jesuscobos2201
@jesuscobos2201 Рік тому
Love your videos. I usually watch all of them just for fun but this has enabled me to speed up a very heavy optimization for my science stuff. Ty for your dedication. I can ensure that it has real world implications :)
@ArtML
@ArtML Рік тому
\o/ Yay! Long waited multiprocessing video! Always appreciate the humor in intros! :D Thanks a lot, I am on a path of making parallelization / multiprocessing to become a second nature in my coding - these videos help greatly! More topic suggestions: - Simple speed-ups using GPUs - Panda speedup by Dask - unlocking multiple cores - Numba, JAX and the overview of JIT compilers - Cython, and the most convenient (easy-to-use) wrappers for C++ implementations - All about Pickling, best practices/fastest ways to write picklers for novel objects
@ajflink
@ajflink Рік тому
And GPU speedups without Nvidia.
@SpeedingFlare
@SpeedingFlare Рік тому
That pool thing is so cool. I like that it spawns as many processes as there are cores available. I wish my work had more CPU bound problems
@michaelwang3306
@michaelwang3306 Рік тому
The clearest explanation on this topic that I have ever seen! Really nice!! Thanks for sharing!
@OutlawJackC
@OutlawJackC Рік тому
Your explanation of the GIL makes so much more sense than other people :)
@jakemuff9407
@jakemuff9407 Рік тому
Great video! Maybe some more "real world" examples would be useful. Knowing that my code *could* be parallelized and actually parallelizing the code are two very different things. I've found that knowledge of multithreading in python does not translate to automatic code speed up. And of course no two problems are the same.
@MrTyty527
@MrTyty527 Рік тому
I think it is more about doing experiments on asyncio/threading/multiprocessing on your own - everyone has different Python use cases
@ibrahimaba8966
@ibrahimaba8966 Рік тому
multithreading is for io bound tasks, i use multiprocessing with zeromq to do some extensive image processing tasks!
@chndrl5649
@chndrl5649 Рік тому
Take crawling as example, it would be a huge time saver if you want crawl multiple words at a time
@chndrl5649
@chndrl5649 Рік тому
It all depends on how you can split your work.
@v0xl
@v0xl Рік тому
python is not the right tool for high performance applicatons anyway
@knut-olaihelgesen3608
@knut-olaihelgesen3608 Рік тому
You are actually the best at advanced python videos! Love them so much
@michaellin4553
@michaellin4553 Рік тому
The funny thing is, adding random noise is actually a useful thing to do. It's called dithering, and is used nearly everywhere in signal processing.
@tommucke
@tommucke Рік тому
You would however apply it to the analog signal at about half the sampling rate in order of getting better results for the digital signal (and smoothen it with a capacitor afterwards). It makes no real sense to add it on the digital side which is the only thing python can do
@gamma26
@gamma26 Рік тому
@@tommucke Unless you're doing image processing and want to achieve that effect I suppose. Pretty niche tho
@maxim_ml
@maxim_ml Рік тому
It can be used as data augmentation in training a speech recognition model
@louisnemzer6801
@louisnemzer6801 8 місяців тому
'I'm going to need those sound files with random noise added in my email inbox by five pm' 😅
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Рік тому
5:07 Threading is also useful for turning blocking operations into nonblocking ones. For example, asyncio provides nonblocking calls for reading and writing sockets, but not for the initial socket connection. Simple solution: push that part onto a separate thread.
@piotradamczyk6740
@piotradamczyk6740 Рік тому
I was looking for this kind of lessons for years. please do more.
@robertbrummayer4908
@robertbrummayer4908 Рік тому
Great video! Man, your videos are awesome. And every time I learn a little bit and get a little bit better, like you say :) Best wishes from Austria!
@HomoSapiensMember
@HomoSapiensMember Рік тому
really appreciate this, struggled understanding differences between map and imap...
@daniilorekhov9191
@daniilorekhov9191 Рік тому
Would love to see a video on managing shared memory in multiprocessing scenarios
@nocturnomedieval
@nocturnomedieval Рік тому
This is so good and clear. A must share. BTW, how these techniques relate to the case when you are using numba with option parallel=True?
@codewithjc4617
@codewithjc4617 Рік тому
This is great content, I’m a big fan of C++ and Python and this is just amazing
@zemonsim
@zemonsim Рік тому
This video was so helpful ! I recently converted my mass encryption script to use multiprocessing. To encrypt my dataset of 450 Mb of images, it went from an estimated 11 hours to just 10 minutes, doing the work at around 750 Kb per second.
@unotoli
@unotoli Рік тому
So well explained. One nice2have thing - quick tip on how to debug (see summary of time2process) most cpu-intensive tasks (functions, like wav transformation in this case).
@mme725
@mme725 Рік тому
Nice, might play with this when I get off work later!
@joshuaowen1941
@joshuaowen1941 Рік тому
I love your videos man! Absolutely love them!
@StopBuggingMeGoogleIHateYou
@StopBuggingMeGoogleIHateYou Рік тому
Great video. I was not aware of that module! As it happens, I've spent the last six weeks writing something that can run thousands of processes and aggregate the results. I'm not going to throw it away after watching this video, but I will ponder how I might've designed it differently had I known.
@walterppk1989
@walterppk1989 Рік тому
Brilliant video. Absolutely flipping gold
@neelroshania7116
@neelroshania7116 Рік тому
This was awesome, thank you!
@eldarmammadov7872
@eldarmammadov7872 Рік тому
liked the way to speak about all three modules asynchio, threading, multiprocessingin one vidoe
@volundr
@volundr Рік тому
This is very useful, thank you
@Darios2013
@Darios2013 Рік тому
Thank you for great explanation
@codedinfortran
@codedinfortran 5 місяців тому
thank you. This made it all very clear.
@etopowertwon
@etopowertwon Рік тому
Multiprocessing helped me a lot recently. I had a script that periodically loads lots tons of small XML from netshare, process them and save locally, single thread ran in 30 seconds, multiprocessed ran in about 6 seconds.
@zlorf_youtube
@zlorf_youtube Рік тому
Me learns a new python thing... Starts using it in every fucking uncessary place. Feels good. Really good thing to talk about typical pitfalls.
@dlf_uk
@dlf_uk Рік тому
What are the benefits/drawbacks of this approach vs using concurrent.futures?
@bersi3306
@bersi3306 Рік тому
Answer reside in the difference between concurrency and parallelism. When to use them also makes a lot of difference (here "CPU bounds" problems to solve with parallelism vs "I/O bounds" problems to solve with concurrency). You should also check (in the concurrent side) the difference between a Threaded function vs a coroutine.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Рік тому
9:27 Actually, there is a faster way of sharing data between processes than sending picklable objects over pipes, and that is to use shared memory. Support for this is built into the multiprocessing module. However, you cannot put regular Python objects into shared memory: you have to use objects defined by the ctypes module. These correspond to types defined in C (as the name suggests): primitive types like int or float, also array and struct types are allowed. But avoid absolute pointers.
@user-uc6wo1lc7t
@user-uc6wo1lc7t 5 місяців тому
Aren't Managers a way to store shared python classes (via register)?
@talhaibnemahmud
@talhaibnemahmud Рік тому
Much needed video. I recently had to use multiprocessing for Image Processing & AI Game Assignment at the university. Although I used concurrent.futures.ProcessPoolExecutor() , this seems like a good option too. Maybe a comparison between these different options? 🤔
@iUnro
@iUnro Рік тому
Hello. Can you explain what is the difference between multiprocessing and concurrent futures package? For me they look the same so I wonder why did you chose one over another.
@pamdemonia
@pamdemonia Рік тому
It's really interesting to see the threading results, (avg ~.2.5sec per file, but only 7.6 sec total). Cool.
@cjsfriend2
@cjsfriend2 Рік тому
You should do a video on using logging alongside with the multiprocessing pool
@akalamian
@akalamian Рік тому
Great teaching, simple and effective, I've using this Multiprocessing with my coroutin, my program is flying, lol
@riccardocapellino9078
@riccardocapellino9078 Рік тому
I tested this on my old code used for my thesis, which basically performs the same calculation hundreds of times with no I/O (calculates flows in a aircraft engine turbine stage). Took me 10 minutes to adjust the code and made it 40% FASTER
@flybuy_7983
@flybuy_7983 Рік тому
THANK YOU MY BROTHER FROM ANOTHER COUNTRY AND ANOTHER FAMILY!!!
@SkyFly19853
@SkyFly19853 Рік тому
Very useful for video game development.
@GaryHost-qs9pg
@GaryHost-qs9pg 6 місяців тому
Very well done video. thank you
@mostafaomar5441
@mostafaomar5441 2 місяці тому
Very useful. Thank you so much.
@s7gaming767
@s7gaming767 Рік тому
This helped a lot thank you
@Lolwutdesu9000
@Lolwutdesu9000 Рік тому
While I'm not using multi-threading in my current work, I'll definitely save this video so I can one day return to it!
@down4good
@down4good Рік тому
You are the only person i keep video notis on for
@POINTS2
@POINTS2 Рік тому
Yes! Pool is the way to go. Definitely an improvement the threading and allows you to not have worry about the GIL.
@jonathandawson3091
@jonathandawson3091 Рік тому
Not always an improvement. A process costs a lot more overhead as he explained in the video. Other languages don't have the stupid GIL, hope that it's also removed from python someday.
@sebastiangudino9377
@sebastiangudino9377 Рік тому
@@jonathandawson3091 It's a safety measure, it'll probably never be removed from python. If you really need "unsafe" threads you could probably just write your threaded function from c and inter-opt it with python. What her that's actually worth it is up you you but a lot of times it is not
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Рік тому
The GIL is an integral part of reference-counting memory management. Getting rid of it completely means moving to Java-style pure garbage collection, where even the simplest of long-running scripts could end up consuming all the memory on your system. There is a project called “nogil”, which sets out to loosen some GIL restrictions a bit. That should give some useful speedups, without abandoning the GIL altogether.
@aleale550
@aleale550 Рік тому
Great video! You could do a follow up parallel computing video using Dask?
@AntonioZL
@AntonioZL Рік тому
Very useful. Thanks!
@Romenamath
@Romenamath Рік тому
My library (hokohoko) uses this. It wont be much use to most people, but i spent a goid deal of time optimising it as it was analysing gigabytes of data with massively cpu-bound operatiobs (for my masters thesis). One takeaway was you really have to plan your shared memory strategy, or that becomes a bottleneck quite easily - system calls add a lot of overhead so you want to minimize those).
@matejlinek287
@matejlinek287 Рік тому
Wow, finally a mCoding video where I didn't learn anything new :-D Thank you so much James, now I can rest in peace :)
@user-zu1ix3yq2w
@user-zu1ix3yq2w Рік тому
i went down a rabbit hole, MP, numba, cython, pypy... The speedup people can get is insane.
@nocturnomedieval
@nocturnomedieval Рік тому
Could you please help me to find the answer: numba with option parallel=True how it relatesto cores/threads/process? @D:
@quillaja
@quillaja 12 днів тому
god that's so much easier than what i've been doing writing all the coordination junk around queue
@dinushkam2444
@dinushkam2444 Рік тому
Great video Very interesting stuff
@replicaacliper
@replicaacliper Рік тому
I'm using Numba to optimize a program and I'm getting ~100% CPU usage. I want to run this program multiple times with independent parameters. In this case, would multiprocessing provide any real benefit over running the program one at a time?
@SageBetko
@SageBetko Рік тому
If Numba is already fully utilizing all CPU cores, then no, the overhead of adding Python’s multiprocessing into the mix will probably just slow things down.
@JohnZakaria
@JohnZakaria Рік тому
If numpy / scipy do the computations in C land, why don't they release the GIL and aquire it back when the computation is done? When writing a C++ module using pybind11, you have the option to release the Gil, granted that you are doing pure C++.
@julius333333
@julius333333 Рік тому
pretty sure it does
@JohnZakaria
@JohnZakaria Рік тому
@@julius333333 if it did, then threads would speed up the computation. Just like i/o calls that do release the GIL
@jheins3
@jheins3 Рік тому
Not an expert but far and based on your comment, you probably know 100x more than I do. With that being said I am going to speculate that the traditional behavior of numpy/scify follows a standard api call to an external C/C++ optimized library (a dll in windows). The API is essentially a function that initiates the c-land magic. For error handling and for how the GIL works, the function call waits to receive the output from c-land before handing it back. Because the API is essentially a function call, the GIL cannot be released till the function returns. Again that's a guess.
@mingyi456
@mingyi456 Рік тому
Please make a video about pickable objects and pickling, I would like to know more about it.
@plays1361
@plays1361 Рік тому
Great video, the program works great
@Kamel419
@Kamel419 Рік тому
I had to solve a complex problem similar to this and ended up needing to use a specific sequence of queues and workers to solve it. I think I ended up with 6 total workers, each with a "parent" worker flowing into it. I think it would be neat to showcase something like this
@felixfourcolor
@felixfourcolor Рік тому
More videos on threading/asyncio please 😊
@hicoop
@hicoop Рік тому
Such a good video!
@ali-om4uv
@ali-om4uv Рік тому
It would be great if you could show if this can be used for Ml hyperparamerer tuning and other Ml tasks.
@pranker199171
@pranker199171 Рік тому
Please do some more real world examples this is amazing
@Roule_n_Scratche
@Roule_n_Scratche Рік тому
Hey mCoding, could you make an video about Cython?
@jaimedpcaus1
@jaimedpcaus1 Рік тому
This was a great Vid. 😊
@tanveermahmood9422
@tanveermahmood9422 Рік тому
Thanks bro.
@EvanBurnetteMusic
@EvanBurnetteMusic Рік тому
This is great! Thanks! Would love a guide on how to use shared memory with multiprocess. I've been optimizing a wordle solver that looks for five words with 25 unique letters as in the recent Stand Up Maths video. On my 8 core machine, each subprocess ends up using half a gig of memory! My data structure is a list of variable length sets. With pool I have to resort to pool.starmap(func, zip(argList1, argList2)) to pass all the data I need into each subprocess. Compared with my naive manual multiprocess implementation, the mp pool version is 30% slower. I'm hoping it can be faster with shared memory. Again, I really appreciate that you created an almost real world problem to demonstrate multiprocessing. It gave me the context I needed to implement this with my program.
@volbla
@volbla Рік тому
I tried using multiprocessing on my prime number sieve where each process have to write to the same array. It didn't really end up being faster (i'm probably bottlenecked by ram speed), but i did get the shared memory to work with numpy arrays. In your main process you do: shared_mem = SharedMemory(name = "John", create = True, size = #bytes) an_array = np.ndarray((#elements,), dtype = #type, buffer = shared_mem.buf) # Put your data in the array And in each subprocess you reference the memory by basically doing the same thing again. shared_mem = SharedMemory(name = "John") an_array = np.ndarray((#elements,), dtype = #type, buffer = shared_mem.buf) # Do something with the data In this case it was also useful to pass the process inputs through a Queue rather than function arguments. Then they only have to be instantiated once, even when consuming a lot of unpredictable data.
@EvanBurnetteMusic
@EvanBurnetteMusic Рік тому
@@volbla Thanks for the queue tip I will definitely be trying that out!
@austingarcia6060
@austingarcia6060 Рік тому
I was about to do something involving multithreading and this video appeared. Perfect!
@SalmanKHAN.01
@SalmanKHAN.01 Рік тому
Thank you!
@czupryn0135
@czupryn0135 Рік тому
If i have an lost of x,y coordinats and i need to calculate distance between each one of them. so to make it faster i cut the 1000 elements array into 5 samller 200 elemnts arrays. than how do i make fisrt core process 1 array, second core the 2 one and so on?
@firefouuu
@firefouuu Рік тому
I still not sure why the wavfile.read is able to run in parallel thread despite the GIL. Is it just because it's C code ? So, if for any reason this was written in pure python this would not work ?
@anihilat
@anihilat Рік тому
Great Video!
@tobiasbergkvist4520
@tobiasbergkvist4520 Рік тому
On Linux/macOS you can use the fork-syscall to "send" things that can't be pickled, but only when using `Process`, and not when using `Pool`, since the process needs to get all the unpickleable data at startup, and can't receive it after it has started. The child processes inherits the parents memory with copy-on-write when using `fork`, meaning it only creates a copy of the memory if an attempt to modify it is made.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Рік тому
2:07 Remember that “I/O” can also include “waiting for a user to perform an action in a GUI”.
@caiomazzaferroadami
@caiomazzaferroadami 5 місяців тому
Can somebody help me out? I'm trying to put some of the things he mentioned in the video in practice and ran through something weird. In 5:50, he uses the iterable object from pool.imap_unordered() to print the return arguments from 'etl' function (filename and duration) for each element in the sounds list. I'm trying to do something similar, but my function (equivalent to his 'etl') returns just one argument instead of two. However, when I try to print each element from that iterable object, my program just freezes and I have to kill it. I can't figure out what's wrong. Note: when I convert it into a list, i. e. list(pool.imap_unordered(fcn, iterable)), it seems to work fine for some reason.
@m0Ray79
@m0Ray79 Рік тому
And don't forget that pure Python is not an only option. Pyrex, which is translated to C/C++, opens even more broad bridges towards performance.
@user-xh9pu2wj6b
@user-xh9pu2wj6b Рік тому
Why use Pyrex when there's Cython tho?
@m0Ray79
@m0Ray79 Рік тому
@@user-xh9pu2wj6b Pyrex is a python language superset. Cython is its translator. I metioned it in my videos.
@user-xh9pu2wj6b
@user-xh9pu2wj6b Рік тому
@@m0Ray79 Cython is also a python superset tho. And no, Cython isn't a translator for Pyrex, it's a separate thing that was influenced by Pyrex back then. And Pyrex is kinda dead with its last stable release being 12 years old.
@m0Ray79
@m0Ray79 Рік тому
​@@user-xh9pu2wj6b The syntax and the whole idea was introduced in Pyrex, I'm still calling it the old name. Ok, let's say Pyrex became Cython. And the file extension is still .pyx.
@pschweitzer524
@pschweitzer524 8 місяців тому
Now the question: would running threads within each multiprocess process be even faster?
@nikolastamenkovic7069
@nikolastamenkovic7069 Рік тому
Great one
@lakeguy65616
@lakeguy65616 7 місяців тому
I have a somewhat related question(s). I have a function where I open a file, perform a number of functions and then write the file to disk. without multiprocessing, it takes 1-2 minutes per file. I've modified my code to take advantage of the multi-cores on my pc. Its reduced the time by a factor of 3+. My problem is that its maxing out the CPU at 100% until the function finishes which means I can't use the pc for any other purpose while the multiprocessing is taking place. Heres my question. How can I reduce the work load on the CPU (even if it takes a little longer)? To process 100 files take at least 45 minutes. eventually I have 500+ files to process.... Any ideas? thank you!
@therelatableladka
@therelatableladka 6 місяців тому
from multiprocessing import Pool # Specify the number of cores to use num_cores = 4 # Change this to the desired number of cores with Pool(processes=num_cores) as pool: # Your code here Hope it helps
@goowatch
@goowatch Рік тому
You should preferably use per-core display to better show what you want to explain. Thanks for sharing your experience.
@necbranduc
@necbranduc Рік тому
Awesome! What about using apply_async vs map?
@maheshcharyindrakanti8544
@maheshcharyindrakanti8544 Рік тому
took me a while due to mistake, but it works thanks
@alexh7849
@alexh7849 Рік тому
Hey mcoding! I think a video discussing how False == 0 in python would be neat (especially since it caused a bug in prod for me lol), it was unexpected they would implement that and make bool subclass int as modern langs like rust/go have ditched the low level concept of bools being ints, maybe include the history of c bools too?
@nocturnomedieval
@nocturnomedieval Рік тому
I think it was already discussed in the video about 25 common python errors. Take a look
@user-fe2oh8oj2u
@user-fe2oh8oj2u Рік тому
Are there any potential dangers/threats when using these methods? I understand that you can slow your program down instead of giving it speed, but besides that ? Any dangers to the computer itself or the data source (if it is coming from a database) ?
@tehseensajjad1003
@tehseensajjad1003 Рік тому
Im learning stuff myself though here's what i can say about databases. Corrections/additions are welcome. Usually there are specialized drivers for doing stuff asynchronously with the database. Also ACID should take care of not ruining the database. As for damage to the computer, no. This is the intended way of doing things in a multi core processing unit. Dont be scared to push your computer. Altough the robot uprising hasnt happened yet, its safe to say, Computers are not humans.
@user-fe2oh8oj2u
@user-fe2oh8oj2u Рік тому
@@tehseensajjad1003 , thank you for your reply. I am planning to experiemnt with some of these methods for my projects. Let's see how many "time" gains it will give.
@tehseensajjad1003
@tehseensajjad1003 Рік тому
@@user-fe2oh8oj2u It can get very confusing trying to design your program around doing stuff parallel or concurrent at first, but it'll click one day. Good luck friend.
@etopowertwon
@etopowertwon Рік тому
You don't want to do non-atomic operations that can leak outside. Like in SQL check first something with SELECT and INSERT it if it was not found "if not sql("SELECT Id FROM Table WHERE Table.Foo=1"): sql("insert into Table(Foo) values(1)")" Two processes can try to insert the same value to the table at the same time.
@imnotkentiy
@imnotkentiy Рік тому
-It is the end -ha. All this time i've only been using 1/16 of my true power, behold -nani?!
@steinnhauser3599
@steinnhauser3599 Рік тому
Awesome!
@rabin-io
@rabin-io Рік тому
Any chance for a follow-up using this inside of a Class? And compare it with pathos.multiprocessing?
@joshinils
@joshinils Рік тому
A video on how to figure out which pieces take the most time and optimizing for time would be great. what profilers are there for python, how do i use them, how do i use them right?
@peterfisher3161
@peterfisher3161 Рік тому
"what profilers are there for python" Spyder and PyCharm have built in profilers.
@joshinils
@joshinils Рік тому
@@peterfisher3161 ah, so I'd have to use those IDEs, not VS code... ok I'd rather have some cli solution or one that works with vs code.
@replicaacliper
@replicaacliper Рік тому
Scalene is an amazing profiler especially on Linux
@peterfisher3161
@peterfisher3161 Рік тому
@@joshinils Quickly looking up I found cProfile, which is a built-in and can be used from the terminal. Not much popped up on VS code.
@jbusa5dimvzgkiik
@jbusa5dimvzgkiik Рік тому
I've found yappi + gprof2dot to be really useful to find where asyncio applications are spending the CPU time.
@mcnica89
@mcnica89 Рік тому
What is this, a CPU monitor window for ants? It needs to be at least 3 times as big! Joking aside, I enjoyed the video and learned something! The pitfalls are especially helpful. Thank you :)
@cute_duck69x3
@cute_duck69x3 Рік тому
Awesome voice and helpfull video 😍
@chrysos
@chrysos Рік тому
I feel more than just informed
@botondkalocsai5322
@botondkalocsai5322 Рік тому
Can async be used in conjuction with multiprocessing?
@unperrier5998
@unperrier5998 Рік тому
Can't wait for PEP 554 multiple interpreters to be mainline.
@adityaalmighty1
@adityaalmighty1 11 місяців тому
The function inside Pool() does not read global variables. Can you please show a way to fix that? It has something to do with this Queue() class, isn't it? The Docs are a bit confusing
@ewerybody
@ewerybody 5 місяців тому
This is cool and all for relatively small python scripts. What if I have a UI (maybe Qt for Python) and want to kick off some work on a pool of processes. I wouldn't want these processes to load (or even execute) any of the UI code 🤔
@renancatan
@renancatan Рік тому
very nice! Just a hint, you know so much about classes, functions, etc Why not make an OOP for beginners? Much beginners/interdemediary still struggle with the most basic expressions from classes..
@maxtulgaa7360
@maxtulgaa7360 Рік тому
Thx
@emilfilipov169
@emilfilipov169 Рік тому
OMG you used start and end time as part of the code?!?!?! In the meantime i get rejected on an interview because i didn't know how to write a decorator to do that same task.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Рік тому
2:49 Re “I say "CPU" a bunch but i actually mean "core"” --- remember that the term “core” for “CPU” was coined by Intel (and possibly other chipmakers) when they started putting the circuitry for multiple CPUs onto a single chip. The distinction isn’t really important, except that some proprietary server software from that time had licence fees that were calculated per-CPU, but somehow this was relaxed into “per-CPU-chip slot”. This way, if you had multiple CPUs in one chip, you didn’t have to pay as much as if the chips were in separate slots (which was quite common in servers in those days). Why did it matter? I guess to prevent a revolt by customers angry over licence fees ...
@mahmoudshihab
@mahmoudshihab Рік тому
I didn't quite understand pitfall number 3, when you showed: `items = [np.random.normal(size=10000) for _ in range(1000)] ` Why is this a pitfall? Also, for the fib demonstration... For some reason, fib took 1.35s vs nfib took 35.05s Even the normal implementation took less time than multiprocessing at 12.93s I even copied the fib and n_fib from your github to ensure that I wasn't doing something wrong But I can't seem to replicate your results
@georget8008
@georget8008 Рік тому
I tried to do the same with Anaconda Spyder on Windows 11. Unfortunately I could not reproduce any of the examples in this video. I have used both the multiprocessing and the multiprocess modules. The problem is that: When I am using the "multiprocessing" module, the program waits indefinitely at the for-statement after the map and at the console I get the message "Warning. multiprocessing may need the main file to exist" When I am using the "multiprocess" module, the program waits indefinitely at the same point, however I get no message on the console. What I am trying to do is to break up a large process into a number of subprocesses and after they are concluded, to gather their results, sum them up and continue from that point on. After watching a great number of videos of the issue, I have not met any solution that actually works on Anaconda Spyder Windows 11. Is there anyone with some suggestion? Thank you
Every Python dev falls for this (name mangling)
14:11
mCoding
Переглядів 135 тис.
Modern Python logging
21:32
mCoding
Переглядів 139 тис.
McDonald’s MCNUGGET PURSE?! #shorts
00:11
Lauren Godwin
Переглядів 32 млн
Python is NOT Single Threaded (and how to bypass the GIL)
10:23
Jack of Some
Переглядів 105 тис.
threading vs multiprocessing in python
22:31
Dave's Space
Переглядів 551 тис.
Actually, you CAN divide by zero.
3:52
mCoding
Переглядів 251 тис.
5 Useful Python Decorators (ft. Carberra)
14:34
Indently
Переглядів 77 тис.
Python dataclasses will save you HOURS, also featuring attrs
8:50
Metaclasses in Python
15:45
mCoding
Переглядів 147 тис.
Compiled Python is FAST
12:57
Doug Mercer
Переглядів 78 тис.
How Fast can Python Parse 1 Billion Rows of Data?
16:31
Doug Mercer
Переглядів 129 тис.
A first look at a faster, no-GIL Python
6:56
InfoWorld
Переглядів 6 тис.
Нужно ли чистить ПК от пыли?
0:59
CompShop Shorts
Переглядів 101 тис.
The power button can never be pressed!!
0:57
Maker Y
Переглядів 22 млн