Diagnose slow Python code. (Feat. async/await)

Поділитися
Вставка
  • Опубліковано 16 вер 2024

КОМЕНТАРІ • 363

  • @blueman333
    @blueman333 3 роки тому +192

    All those clickbaity websites and articles NEVER really talked about such a wonderful library that actually is a part of standard library. Today I learnt something new which will be actually helpful.

    • @mCoding
      @mCoding  3 роки тому +26

      Thank you so much! Glad you enjoyed!

  • @sharkinahat
    @sharkinahat 3 роки тому +193

    Performance tuning is usually an appendix in books and courses and the usual suggested solution is either timeit() or re-writing the critical part in c/c++. Thanks for showing a better approach.

    • @bva0
      @bva0 3 роки тому +18

      This!! There's a book on Cython that right in the beginning shows how important it is to profile the code before attempting anything more elaborate, so as to not waste effort on something that isn't a bottleneck

    • @dadestor
      @dadestor 3 роки тому +3

      well profiling is basically timing and if you need high speed python won't cut it anyways no matter what you do with it

    • @ApiolJoe
      @ApiolJoe 3 роки тому +15

      @@dadestor What if you can reach something fast enough with some refactoring instead of rewriting in another language? Via profiling you can see quite easily if the program is spending a lot of time in functions that should not take much time, in which case you know what to refactor.
      Profiling can also help you see which parts of the program need to be particularly well written in the next language and which ones are not too critical on performance.
      Not exactly sure why you made your comment sound like you consider profiling as a waste of time.

    • @dadestor
      @dadestor 3 роки тому

      @Andrii Shafar v8 is good, but it's still an interpreted (or JIT -ed) language

  • @BakkarGraphics
    @BakkarGraphics 3 роки тому +325

    I never expected to learn such a thing, this channel is full of stuff that i never expect to learn, thanks man :)

    • @mCoding
      @mCoding  3 роки тому +33

      Happy to hear that!

    • @gokublack4832
      @gokublack4832 3 роки тому +15

      exactly, that's why I love this channel, lots of beginner content out there, but not as much intermediate/advanced stuff and that's what we get here

  • @THEMithrandir09
    @THEMithrandir09 3 роки тому +91

    Just to make it clear, what makes async so powerful is that it allows a cpu-python-process to parallelize waiting, in this case for responses from the network card. It is useful for data I/O to other devices, but it usually won't speed up stuff like costly operations on huge data-arrays. For that, multiprocessing is the way to go. If you happen to not like async for some reason, threading does basically the same thing, but as a different concept.

    • @bva0
      @bva0 3 роки тому +3

      Thank you for the post, I didn't know of async, just multithreading and multiprocessing.
      Do you reckon it may be advantageous to use async when scheduling workers in a master/slave paralellization paradigm? Then again, I think OpenMP does this "by default" doesn't it? 🤔
      (Bare in mind my understanding of these things is rather superficial, since OpenMP can be used in Cython via a fairly high level api)

    • @THEMithrandir09
      @THEMithrandir09 3 роки тому +5

      @@bva0 Since the trend away from monolithic software to microservices is huge right now(and for good reason), whenever I hear keywords like master/slave or multiple workers, I always check if microservices make sense over classical concurrent processing. The additional networking overhead is usually neglible thanks to great tools like gRPC and once you have the architecture set up, scaling from one server to entire datacenters, the roadmap is suddenly just a (complicated) recipe you follow instead of a monstrous engineering problem.
      So if you run multiple slave workers anyway, I'd rather run more single process workers that are ephemeral instead of dealing with concurrency in monolithic software.
      There's the 1% of cases where this won't go well, e.g. training neural nets, but for those few cases there exist great compute frameworks already, e.g. tensorflow and pytorch.
      But sometimes the solution/problem is small enough and you really only want to parallelize waiting and/or are limited by some device I/O, then doing async or threading to do that can be a great choice for sure!
      HTH

    • @bva0
      @bva0 3 роки тому +2

      @@THEMithrandir09 Thanks for the reply! I mainly use sparse direct solvers for optimization problems in mechanical engineering. Though I've been trying to migrate to sparse iterative solvers for HPC.
      I'll spend the next hour or so googling some terms in your answer, before asking further questions! Lol
      Edit: and yes, I use Tensorflow for some neural network problems! Though I find it difficult to fully understand the equivalence between certain numpy and tensor functions in order to fully get the benefits of operating in graph mode.

    • @mCoding
      @mCoding  3 роки тому +92

      I'm thinking of having a "when to use async vs multithreading vs multiprocessing vs nothing" video but first I need to introduce all the topics :)

    • @filipbartos7584
      @filipbartos7584 3 роки тому +1

      @@mCoding Thats great idea!

  • @Julie9009
    @Julie9009 3 роки тому +22

    Thank you so much for this very timely video. I had an app that I presumed was slow because I had some inefficient SQL queries. After profiling, I discovered that the slowdown was actually in a regex that I was running against every returned record. I now only run the RegEx against records that contain certain text. It was taking 38 seconds to run. It now runs in 9 seconds, 8 of which is rendering the Jinja template. This video saved me what would have been many fruitless hours trying to improve the SQL, which turned out not to be the problem.

    • @mCoding
      @mCoding  3 роки тому +2

      So great to hear your success story! I'm glad my video helped!

  • @Neomadra
    @Neomadra 3 роки тому +247

    Could you make a video going in more depth on the difference between async and parallel coding?

    • @mCoding
      @mCoding  3 роки тому +106

      Planning this sometime in the future, we'll see how long it takes to make...

    • @zactron1997
      @zactron1997 3 роки тому +11

      @@mCoding I think this would be a great video. I remember when I first started righting code that needed to be faster my instinct was just "well it's only using 1 core, so if I use all 4 cores it'll be 4 times faster!" Little did younger me know that instead of trying to orchestrate multiple cores all I needed to do was call some of my functions asynchronously to avoid IO bottlenecks.

    • @drishalballaney6590
      @drishalballaney6590 3 роки тому

      yes please!

    • @Luclecool123
      @Luclecool123 3 роки тому

      @@mCoding please talk about gevent

    • @vornamenachname906
      @vornamenachname906 3 роки тому +1

      wtf. even the plain words scream the difference in my face. the difference is so obvious. dont know why its even a topic worth.

  • @onedez
    @onedez 9 місяців тому +1

    Essentially, in the slow example, you're doing every get request one at a time, waiting for the first to finish before moving on to the next one. In the asynchronous example, you start all of the requests at the same time, doing them simultaneously, then wait for all them to finish before moving on.

  • @benixmo
    @benixmo 3 роки тому +1

    I was using async requests when needed but the profiling tool is a game changer, that was something I did not know existed.

  • @HypnosisBear
    @HypnosisBear 3 роки тому +3

    OMG I've landed on a gold mine.
    This channel is awesome 👍👍👍

    • @mCoding
      @mCoding  3 роки тому +1

      Thank you so much I'm glad you enjoy!

  • @mahdi7d1rostami
    @mahdi7d1rostami 2 роки тому

    I had never heard of anything related to this topic and actually, I had this problem numerous times when trying to do web scraping. That's exactly the problem with all tutorials on the internet. They only cover the basics and that's what makes this video so special for me.

  • @nicolasmiller1915
    @nicolasmiller1915 3 роки тому +17

    Keep it up, great quality content!

    • @mCoding
      @mCoding  3 роки тому +3

      Thanks, will do!

  • @mohammadzuhairkhan8661
    @mohammadzuhairkhan8661 3 роки тому +47

    Can you make more videos on intermediate topics? This is my first time learning about async and it already seems so helpful!

  • @Belissimo-T
    @Belissimo-T 3 роки тому +3

    Your video quality just keep rising!

  • @Chaosman88
    @Chaosman88 3 роки тому +1

    The timing of this video is perfect, I need to profile a GUI that runs a little bit slow, and I have to investigate why :)
    Also I'm looking forward for more profiling videos, this could be a series

    • @mCoding
      @mCoding  3 роки тому +1

      More to come!

  • @arisweedler4703
    @arisweedler4703 3 роки тому +1

    Icicle graph … flame graph ! Wow, python makes that easy. What a wonderful developer experience. It even serves it in your browser for you 😳😱😍

  • @raymond-andrade
    @raymond-andrade 3 роки тому +2

    Awesome content. This literally comes as I had issues with time it took me to process large amounts of data. I spent hours trying to look up videos to speed certain operations up only to find it to have little impact. Can't wait to try this out.

  • @eric-seastrand
    @eric-seastrand 2 роки тому

    Been using python 2 years and never knew it could do async/await. Thanks for this!

  • @josephlyons3393
    @josephlyons3393 3 роки тому +18

    Hey, I have a degree in CS and am employed as a Python dev. I fully understand threads and processes, but never use coroutines/ async-await. Would love an in-depth video in the differences in programming and usefulness, as well as what’s going on under the hood.

    • @bernardcrnkovic3769
      @bernardcrnkovic3769 2 роки тому +2

      basically it relies on user-space context switching which is cheaper than kernel/thread-space context switching done in multithreading. you could do the same with multiple threads but overhead of switching thread contexts would be larger than event loop contexts.

  • @aqualung1466
    @aqualung1466 2 роки тому +3

    This was a terrific video - I just cut a script from 45s to 3s using your technique. Thank you James!

    • @mCoding
      @mCoding  2 роки тому +1

      Awesome! Great to hear and glad that you were able to use snakeviz to go use!

  • @Mekuso8
    @Mekuso8 3 роки тому +3

    I prefer kernprof which can shows your code's execution speed line-by-line which can really help in some situations

    • @bva0
      @bva0 3 роки тому +1

      Cool, first time I read about this

  • @drewbrown1534
    @drewbrown1534 3 роки тому

    This is fantastic. I've been working on a personal project that is sensitive to costly operations, and doing this has helped me significantly reduce runtime. No more guessing at where the problem is!

    • @mCoding
      @mCoding  3 роки тому +1

      Great to hear!

  • @vijaybaskar7635
    @vijaybaskar7635 3 роки тому

    In a world of beginner tutorial, here comes a saviour with intermediate topics. Thanks a ton mate

    • @mCoding
      @mCoding  3 роки тому

      Happy to help!

  • @DaVince21
    @DaVince21 2 роки тому

    I was struggling to find good, simple but practical examples of the advantages of async and await but this has really cleared it up for me.

  • @simonthor7593
    @simonthor7593 3 роки тому +2

    Pycharm also has a builtin run configuration called "profile code" or something like that, so you do not have to write the boilterplate cProfile code. This also shows a nice visualization

  • @FireOnYouTube
    @FireOnYouTube 4 місяці тому

    My code went from taking 47s to 8s then when changing the max concurent requests number I got it down to 4s then finally to 1.4s.
    33x faster.
    Perfect video.

  • @coolpix807
    @coolpix807 7 місяців тому

    Your process of profiling is a big improvement to iterating through profiling output. Very helpful. Thank you for your video tutorial!

    • @mCoding
      @mCoding  7 місяців тому

      You're very welcome!

  • @ChrisHalden007
    @ChrisHalden007 3 роки тому +3

    Wonderful! Thank you so very much for this introduction to profiling.

    • @mCoding
      @mCoding  3 роки тому

      You're very welcome!

  • @niconeuman
    @niconeuman 3 роки тому +1

    Excellent video! Profiling is a super important tool! Your explanation and examples were very clear and useful!

  • @rogervanbommel1086
    @rogervanbommel1086 3 роки тому +6

    Thanks, am a new programmer learning

    • @mCoding
      @mCoding  3 роки тому

      Happy to help!

  • @JohnDoe-wq9pr
    @JohnDoe-wq9pr 3 роки тому

    This is great info...good practical tips, presented to the point, with examples, and without all the time wasting filler content. Even IF it the purpose was to just make the video longer, the additional content was ACTUALLY useful. I'm sure there are plenty of videos on cProfile, but the bit about snakeviz was above and beyond. A lot of other channels that produce instructional videos can learn from this channel.
    I always look forward to more vids from this channel, even if they just randomly pop up on my stream. Time will spent!

    • @mCoding
      @mCoding  3 роки тому

      Thanks for the kind words! Glad you enjoyed!

  • @TheAmPm123
    @TheAmPm123 3 роки тому +3

    Today I learned that if you delete the 2 second sleep it takes 2 seconds off the time...
    Seriously though, great video, thanks :)

    • @mCoding
      @mCoding  3 роки тому +2

      You'd be suprised how easy it it is for a debug sleep or print statement to end up in a prod release ;)

  • @Mufti199
    @Mufti199 2 роки тому +5

    Dude you're content is so refreshing, useful, to-the-point, and just simple superb. I've been bingeing your videos like crazy! Thank you and please keep it up 😊
    P.S. quite surprise I haven't seen any comment about cumtime. Yes, very childish I know but I had to put it out there.

  • @nadavgolden
    @nadavgolden 3 роки тому +10

    More on async in python please!

  • @leotaku5216
    @leotaku5216 3 роки тому +1

    Great video! I'd also really like to see you do a whole video on how to best make use of asyncio. I roughly understand the API, but rarely know how to best make use of the different features. An introduction to your favorite async-powered libraries (e.g. httpx) would also be really helpful.

  • @georgesanderson918
    @georgesanderson918 3 роки тому

    I had a good day today, but this new mCoding video just turned it into an ever better day! I didn't usually profile my code before this, but on my current project, I will. Thank you for the content!

  • @qm3ster
    @qm3ster 3 роки тому +4

    Not gonna lie, expected the "feat. async/await" to be "you are using async where you didn't need to and that is slowing you down" :p

  • @telescopilan
    @telescopilan 2 роки тому +1

    I really appreciate the fact you skipped the running time at 02:00

  • @chazmertes
    @chazmertes 2 роки тому

    Thank you so much for contributing to the community in such a wonderful way!

  • @tincustefanlucian7495
    @tincustefanlucian7495 2 роки тому +1

    Great presentation! Also you can achieve the same speed improvement with multi-threading or multi-processing with one request per thread or process. But that would mean longer video.

    • @mCoding
      @mCoding  2 роки тому +1

      Maybe a topic for a future video for sure! Thanks!

  • @Talon_24
    @Talon_24 3 роки тому +2

    A python video that includes async that is not a) replace a print("Yes") with an async call to a function that calls print("Yes"), or b) Send requests to a webserver that takes exactly 1 second to reply by using socket and make the little change of completely rewriting the entire program to have it use async? In my lifetime? I'm SO going to hit that like button an odd number of times! Thank you!
    Also great to see snakeviz promoted, that was a lifesaver when i found it; If that's helpful for someone, here's a powershell function for calling the script with the profiler:
    Function pyprofile
    {
    python -m cProfile -o $env:TEMP\python_profiling.prof $args
    snakeviz $env:TEMP\python_profiling.prof
    }

  • @SavitskyVadim
    @SavitskyVadim Рік тому

    Masterpiece! Thanks for your effort, I managed to get my hands to keyboard from other side of sofa just to write this comment.

  • @lepsycho3691
    @lepsycho3691 3 роки тому

    Even though I knew just from the code that the web requests were the slowest part, I will definitely use the profiler in my future projects! Thx for the amazing video!

    • @mCoding
      @mCoding  3 роки тому +3

      You are welcome! I know in this case the answer was obvious, but usually it's less obvious in a real project, I just wanted to keep it simple for this little video. Glad you enjoyed!

  • @MultiPokemoncatcher
    @MultiPokemoncatcher 3 роки тому +23

    Amazing, but even though it’s single threaded how does it handle the whole asynchronous part?

    • @calfdindon2353
      @calfdindon2353 3 роки тому +18

      Python magic behind the scene, i think that it gives each task a small cpu time and switches to the next task.

    • @MrChickenpoulet
      @MrChickenpoulet 3 роки тому +3

      Yea like @Calf Dindon said each tasks will be run a bit and a "scheduler" has the role of switching which tasks has to be run.
      I believe it's when we call an `await` statement the scheduler will switch to another task and some kind of callback is set to run the logic once it can.
      If someone could confirmed this that would be great!

    • @mCoding
      @mCoding  3 роки тому +14

      You can read about the event loop design pattern here! en.wikipedia.org/wiki/Event_loop

    • @TheJuniorDev1
      @TheJuniorDev1 3 роки тому +15

      Imagine a teacher setting up kids for a test, but they want the kids to be in and out as fast as possible. So as kids start to line up she starts them on a test -> they start -> if one finishes the teacher goes to their test station -> writes down their score -> and sets up more kids for these tests. As you can see the teacher's only job is to start the kids on their test and not do it for them. Similar to the event loop. Python starts the requests and goes and starts more while waiting for the others to finish if that makes sense.

    • @MultiPokemoncatcher
      @MultiPokemoncatcher 3 роки тому +2

      Yeah thank you everyone, makes a lot of sense. Didn’t realize it was like an event handler of some sort .

  • @philippmatten4320
    @philippmatten4320 2 роки тому +1

    Holy fuck, dude! How do you come up with all these ideas for new videos?! I so enjoy your content! Please keep up the good work! ;)

  • @FutureAirify
    @FutureAirify 3 роки тому +2

    so many interesting videos to learn things here and there, thanks a lot

  • @rtxmax8223
    @rtxmax8223 3 роки тому

    Advanced stuff with so much new stuff to learn about python modules.

  • @alexanderschafer8979
    @alexanderschafer8979 2 роки тому

    15 Iterations with a two second sleep between each one in 12 seconds!! Man, this guy is really fast!!!

    • @mCoding
      @mCoding  2 роки тому +1

      I believe the sleep was outside the loop!

  • @davidblake8612
    @davidblake8612 3 роки тому

    I quite like the profiling function in the Spyder IDE that comes with the Anaconda distribution. You can just hit F10 and it profiles your code and shows the output.

  • @vishalmishra7018
    @vishalmishra7018 Рік тому

    Thank you for making such a high quality video. Amazing.

  • @transistivehq
    @transistivehq 2 роки тому

    Man!
    You create amazing content! Thanks for all.

  • @youngzproduction7498
    @youngzproduction7498 Рік тому

    Nice tricks you put here. Thanks a lot.

  • @PrashantKg1996
    @PrashantKg1996 3 роки тому +1

    Another great video. Can you please make an elaborate video on async and parallel processing? It would be really helpful for people like me who don't have much understanding of such topics.

    • @mCoding
      @mCoding  3 роки тому +3

      It's been in the works for a while... hard to get right!

  • @_Xyr
    @_Xyr 3 роки тому +1

    i learned alot this video yet again, thank you so much!

    • @mCoding
      @mCoding  3 роки тому

      You're very welcome!

  • @alaapsarkar
    @alaapsarkar 3 роки тому

    2:12 very very relatable
    I wish I knew about this a year ago when I was working on my thesis lol, this will be very useful, I always get to learn something new on this channel.

    • @mCoding
      @mCoding  3 роки тому

      There's always a next time!

  • @tobiasbergkvist4520
    @tobiasbergkvist4520 3 роки тому

    line_profiler is nice - and way more intuitive to use than a flamegraph.

  • @kwe4117
    @kwe4117 2 роки тому

    if you made a course I would buy it, you are amazing!

  • @WizardOfArc
    @WizardOfArc 3 роки тому

    I’ve been wanting to know how to profile my Python code! This is SUPER helpful!

  • @ggsap
    @ggsap 2 роки тому

    Could you make a video explanining asynchronous and parallel programming technically? I see many others just give a broad overview of how to use the library, not explain what it does under the hood. Great content!

    • @mCoding
      @mCoding  2 роки тому

      This is on the horizon, but if you are looking for an existing video, David Beasley has a great 2 hour ish video that might go into the detail you are looking for.

  • @Mkemcz
    @Mkemcz 3 роки тому +1

    Nice and informative video. Video coding tutorials are usually a waste of my time since reading text-based tutorials is faster, but somehow your videos are an Exception to the rule.
    BTW: at 8:34 how did you generate that list comprehension? What IDE is this?

    • @botisonny
      @botisonny 3 роки тому +1

      he probably had it copied and just pasted the list comprehension

  • @tahini245
    @tahini245 3 роки тому +1

    For asynchronous HTTP requests, the two main go-to libraries are either this one (httpx) or aiohttp. But is there any speed difference or advantages using one library over the other? Or do they do the exact same thing and it's simply up to personal preference?

    • @tissuepaper9962
      @tissuepaper9962 Рік тому

      That's a question that you would have to answer yourself by reading the parts that you're actually using in a given project and/or profiling your code using both libraries.

  • @Muhammed.Abd.
    @Muhammed.Abd. 6 місяців тому +1

    Woah! Thanks a ton
    Any idea on profiling GUI or flask applications?
    In GUI we have different threads for GUI and one for behind the scene works. I need to profile the backend task threads

  • @ryanking9217
    @ryanking9217 3 роки тому

    This is brilliant, thank you for sharing this. The profiling is going to be really useful at work.

  • @fvgoya
    @fvgoya 3 роки тому

    Extremely helpful and goes straight to the point. This type of content is very, VERY valuable!!!! Thank you!!!

    • @mCoding
      @mCoding  3 роки тому +1

      You are very welcome I'm glad you enjoyed!

  • @matiasmoglia
    @matiasmoglia 3 роки тому +1

    Amazing content and very well delivered, thanks mate!

    • @mCoding
      @mCoding  3 роки тому

      Thanks so much!

  • @bijeshmohan
    @bijeshmohan 3 роки тому +1

    You’re amazing. Keep the good work.

    • @mCoding
      @mCoding  3 роки тому +1

      Thank you very much for the kinds words!

  • @benlong1062
    @benlong1062 2 роки тому +1

    This is a great video. Wow. Thanks!

    • @mCoding
      @mCoding  2 роки тому

      Thank you for your kind words!

  • @jussitamminen1676
    @jussitamminen1676 2 роки тому

    I liked your videos about how to make python run faster!

  • @nitsanbh
    @nitsanbh 2 роки тому

    Opinion: JS has got its async/await much better & easier to use.
    This is the equivalent JS code for the htmls:
    const htmls = await Promise.all(
    urls.map(async (url) => {
    const res = await fefch(url);
    return await res.text();
    })
    );

  • @NostraDavid2
    @NostraDavid2 2 роки тому

    And to answer "yes, but is this still slow?": think about how much data you're processing and how long it takes. That gives you the MBps, and THAT can indicate whether your code is still slow. If you have a super fast machine and super fast internet and the data is only a few megabytes, I would say it's still slow, because modern machines can handle gigabytes of data per second.
    Just a little rule of thumb to know whether your optimized code is still slow.

  • @JamilBousquet
    @JamilBousquet 3 роки тому

    Was not aware of httpx, fully expected you to talk about aiohttp. Thanks for sharing this video it's really helpful. Would love to see your take on multiprocessing in python if you've not already done so.

    • @mCoding
      @mCoding  3 роки тому +2

      My pleasure! Been working on an async/threading/multiprocessing video for a while, it's hard to get right!

  • @uwirl4338
    @uwirl4338 2 роки тому +2

    The actual best, most unequivocal way to make your Python code faster... is reimplementing it in another lenguaje. Even better if you use efficient coding patterns rather than looks the most neat (aka most pythonic). Hurts but I know you can't argue otherwise.

  • @_Zabamund_
    @_Zabamund_ 3 роки тому

    Very useful and nice clean examples. Thank you.

    • @mCoding
      @mCoding  3 роки тому +1

      You are welcome!

  • @MarvinTurner
    @MarvinTurner 3 роки тому

    Amazing and straight to the point. Thanks

  • @Iifesteal
    @Iifesteal 3 роки тому +2

    "Here's the random sleep someone forgot to delete. We can just delete that."
    X doubt. I would instantly test it to see if it still works.

  • @voinywolnyprod3046
    @voinywolnyprod3046 3 роки тому

    Very clear and detailed explanation! Thank you very much!!!

    • @mCoding
      @mCoding  3 роки тому

      You're welcome and thanks for watching!

  • @emifro
    @emifro 3 роки тому

    That looks very useful, ill definitely use it when I need to.

  • @argsahoo
    @argsahoo 3 роки тому +3

    This was really helpful

    • @mCoding
      @mCoding  3 роки тому +3

      Awesome, glad you think so!

  • @BlackHermit
    @BlackHermit 3 роки тому

    snakeviz is awesome! Thanks James!

    • @mCoding
      @mCoding  3 роки тому

      You bet! Thanks for watching again!

  • @gerozayas9425
    @gerozayas9425 Рік тому

    Your channel is amazing! thanks a lot for such excellent and useful content!

  • @guydht1
    @guydht1 24 дні тому

    Do note that this specific code block is *not* production ready - since it uses a blocking non-async reading of a file in an asynchronous environment ("with open(...)"). If for example that were to happen in an async web-server, that would be a horrific performance problem, making the whole server wait on that one read between all concurrent requests. Async in python is "colored functions" which is hard and sucks.

  • @hshhsjhahsvs7728
    @hshhsjhahsvs7728 2 роки тому +1

    Liked and subscribed!! That was helpful

    • @mCoding
      @mCoding  2 роки тому

      Great to hear! Welcome to the community!

  • @Mrjulle3
    @Mrjulle3 3 роки тому +2

    Httpx ftw!

    • @mCoding
      @mCoding  3 роки тому +2

      I know, I can't wait for it to hit 1.0!

  • @TNeulaender
    @TNeulaender 2 роки тому

    Great focus on the task, but the non pythonic sums drive me crazy :D

  • @chinnku
    @chinnku 3 роки тому

    Keep up the great content mate!
    Really helpful. Cheers!

    • @mCoding
      @mCoding  3 роки тому +1

      Thanks, will do!

  • @stifferdoroskevich1809
    @stifferdoroskevich1809 3 роки тому

    AMAZING! Thanks for sharing!

    • @mCoding
      @mCoding  3 роки тому

      You are very welcome! Glad you enjoyed!

  • @falcao_g
    @falcao_g 3 роки тому +1

    this was really helpful, thank you!

    • @mCoding
      @mCoding  3 роки тому +1

      Glad it was helpful!

  • @moastevenson7748
    @moastevenson7748 2 роки тому

    Brilliant! Thank you.

  • @darkchoclate
    @darkchoclate 2 роки тому

    Funny thing is, i made a project that does the 3n1 check for a long range of number, and save the step and result in a file... I wrote in both c++ and python, surprisingly python took half as much time... i guess python is better in writing optimized c++ code than me😅😅

  • @khalilrouatbi6345
    @khalilrouatbi6345 2 роки тому

    beautiful! i like the content of this channel.

  • @hzi88
    @hzi88 2 роки тому +1

    You really should have also shown profilehooks. It is just so much more convenient to add a decorator to a function call. It is easy to do and easy to remove then adding all the with ... blocks in the code. It has its limitations but to profile a single function at a time it is quite good and fast to use.

  • @alexwhb122
    @alexwhb122 3 роки тому

    Yet another fantastic video. Thanks for this. I learned a lot! Do you ever use the profiler in PyCharm?

    • @mCoding
      @mCoding  3 роки тому +1

      I use the free version of PyCharm :S so no profiler for me.

    • @alexwhb122
      @alexwhb122 3 роки тому

      @@mCoding I actually did not realize that was a difference between the pro and free version. Makes sense. I'd go free as well if my job did not pay for my license. I also did not know about the asyncio lib... so that's also a handy tip. 👍Keep up the good work. Love your videos. It's nice to find more technical content... in my experience most python videos I see are either way to basic or a good level of complexity, but the explanations suck or the production quality is bad... so you hit a really nice balance.

  • @robertbrummayer4908
    @robertbrummayer4908 3 роки тому

    Excellent and very interesting

  • @JohnDlugosz
    @JohnDlugosz 3 роки тому +1

    How about benchmarking the same task done with Perl 5?

  • @CritiKaster
    @CritiKaster 2 роки тому

    @mCoding Love you videos and explanations! I'm a big fan and hope to see more of your content. Very interested in this example - however I notice that the resulting http/https counters are way higher that the synchronous function - many of the asynchronous responses are just empty - is this a bug or a feature? Would love to understand this better. Thanks in advance!

    • @CritiKaster
      @CritiKaster 2 роки тому +1

      Ah found it - turns out the website URLs allmost all served a 301 redirect - fixed it by adding `follow_redirects=True` to the client.get line, so the full line is:
      tasks = (client.get(url, follow_redirects=True) for url in urls)

  • @aaronbrant6149
    @aaronbrant6149 2 роки тому

    Thank you so much for your videos, by the way , Can you tell me which software did you use to record the video? How to put the speaker in the video, I also want to use. Thank you so much.

    • @mCoding
      @mCoding  2 роки тому +1

      I'm using obs studio to record, and I have a grewn screen behind me so I can use the chroma key filter to make the background transparent.

  • @tushargupta764
    @tushargupta764 3 роки тому

    How do you get to know these stuff ? Suggestions for resources where I can find them ( apart from open source projects ). Something like good blogs etc. Where they break down things a little for you effectively ?

  • @wduandy
    @wduandy 3 роки тому

    I love it! Just love it!

    • @wduandy
      @wduandy 3 роки тому

      Like + Fav on it!

    • @mCoding
      @mCoding  3 роки тому

      Thanks so much 🙏

  • @MSemih-dk6xp
    @MSemih-dk6xp 3 роки тому

    KUDOS!! Sincerely, I want you to thank you for your great videos!! I quite appreciate the knowledge you're sharing with us

    • @mCoding
      @mCoding  3 роки тому

      Thank you very much!

  • @Kram1032
    @Kram1032 3 роки тому

    Really deepdiving into coroutines would be great

  • @SodaWithoutSparkles
    @SodaWithoutSparkles 3 роки тому +1

    I have a simular situation.
    My intention is to get links from a webpages and download the files from said links.
    My solution is to use a loop to browse through webpages and get the links, then download them.
    Would it be better to write all the links to a file first then downloading it?

    • @mCoding
      @mCoding  3 роки тому

      It doesn't matter much whether you write the links to a file (though you may want to do that for your records), the important part is that you download the files asynchronously just like we download the pages themselves asynchronously in this video. Just keep in mind that automated downloading of files may be against the terms of service of a site even if you would have access to download all of the files by hand.