How To FIND SLOW CODE In Python & OPTIMIZE IT (FT. cProfile)

Sdílet
Vložit
  • čas přidán 22. 10. 2022
  • Today we will be discovering together how we can use cProfile to find slow code in our program, and thanks to this, we can also further optimize our slow code.
    Docs: docs.python.org/3/library/pro...
    ▶ Become job-ready with Python:
    www.indently.io
    ▶ Follow me on Instagram:
    / indentlyreels

Komentáře • 31

  • @zer0her058
    @zer0her058 Před 7 měsíci +13

    3:23 😂 no way he called it that

    • @jp46614
      @jp46614 Před 5 měsíci +2

      the what time???

    • @itsdarklikehell
      @itsdarklikehell Před 4 měsíci +1

      ah my favorite time of the day, let me get my lotion and tissues!

  • @dcknature
    @dcknature Před rokem +3

    cProfile seems to be a rather helpful tool for development.
    As always thanks and 24-th 👍😉!

  • @ryzer9699
    @ryzer9699 Před rokem +5

    Can you do a tut of how to protect python code and implant license's system to it? Or even provide me with some useful resources to learn from?, Btw great video. Thanks!

    • @JackSparrow-vh8zz
      @JackSparrow-vh8zz Před rokem

      If you want to freeze your Python code to exe then pyinstaller works great

  • @maxcharacterlimitreache-

    Your channel is a godsend for this knowledge snippets

    • @Indently
      @Indently  Před rokem +1

      Grazie bello :) Si sono mezzo Italiano, l'altro mezzo e' un mistero ahah

    • @GooogleGoglee
      @GooogleGoglee Před rokem

      @@Indently Aahhh lo sapevo!
      Bravo! Bel canale
      Sei in Danimarca?

    • @Indently
      @Indently  Před rokem

      @@GooogleGoglee Si! Gia da 7 anni ormai :)

    • @GooogleGoglee
      @GooogleGoglee Před rokem

      @@Indently hai fatto bene! 👍🏻👋🏻 congratulazioni, beato te! Avrei tante domande da farti ma purtroppo non è il posto giusto.

  • @yabool2001
    @yabool2001 Před rokem

    That's great!

  • @ewerybody
    @ewerybody Před rokem +1

    3:32 link is not in the description box :/
    But before you post that answer from 10 years ago why not link the latest docs for the stuff?

    • @Indently
      @Indently  Před rokem +1

      That's a fair point, it was just faster to find on stack overflow than scrolling down half way through the documentation. But I've gone ahead and included it!

  • @csd4ni3l
    @csd4ni3l Před rokem

    thank you

  • @cheezedoodles3447
    @cheezedoodles3447 Před rokem

    hey! there's actually a better profiler called scalene, you should check it out

    • @Indently
      @Indently  Před rokem

      Thanks for the heads up! I will check it out!

    • @ewerybody
      @ewerybody Před rokem

      its not built-in tho, right? :)

  • @ewerybody
    @ewerybody Před rokem +1

    0:56 did you know that Python functions always return None if not explicitly told otherwise?

    • @Indently
      @Indently  Před rokem +2

      I think I was a bit zombified from all the recording I did that day ahah. Reminds me of the times I returned True if something was True and False if it wasn't.

    • @rivers.thr33
      @rivers.thr33 Před rokem

      true, though sometimes i use it to mean "this returned None for a reason" instead of "this returns None always". ended up saving me some dev time when i found myself writing a "Null" class later

  • @cirklare
    @cirklare Před rokem +1

    I think Cython (C python)
    Is a bit faster than normal python libs

    • @ewerybody
      @ewerybody Před rokem +1

      Cython != Cpython

    • @ewerybody
      @ewerybody Před rokem +1

      "Normal python libs" could also be compiled with cython. So this statement doesn't make much sense.
      You mean code compiled with cython might execute faster than when executed with default cpython?
      That might be true. cProfile is still useful.

    • @cirklare
      @cirklare Před rokem +1

      @@ewerybody thank you, actually I used cython for one time

    • @cirklare
      @cirklare Před rokem +1

      @@ewerybody I know, but I call it that way for no reason

  • @TypicalPythonCoder
    @TypicalPythonCoder Před 5 měsíci

  • @OnlyKemal
    @OnlyKemal Před rokem

    hi