2 Reasons Why Your Python Script Runs Slow

Опубликовано: 09 Декабрь 2022
на канале: Bitswired
553
9

I'm here today to talk about why your Python script runs slow.

Let's get into the top 2 reasons!

Number one: Poor Data Structures. If your data is stored inefficiently, it can take a lot of time for the script to process. So make sure you're using the right data structure for the job.
For example, if you often check the presence of an item in a list, you might use a set that can do it in constant time (instead of linear time for a list).
Checkout the TimeComplexity page on the Python wiki for details about all the data structures : https://wiki.python.org/moin/TimeComp...

Number two: Unnecessary Computations. If your script is doing too much work, it will take longer. Try to optimize your code to reduce the number of computations.
For example, use caching if you do over and over the same computations. It's easy and will save you lots of time.
So there you have it! Those are my top 2 reasons why your Python script is slow.


Hopefully you liked this video 💚
🔥 Subscribe to Bitswired
👍🏽 Leave us a like/comment to support us

💬HASHTAGS:
#python #pythonprogramming #codingtips #coding #programming #learnprogramming #learnpython #learncoding #interview #cofinginterview #optimization #slow #fast #peoplewhocode #codinglife #shorts #short