Why is Python slow?

codebasics · Beginner ·🖌️ UI/UX Design ·5y ago

Key Takeaways

This video explains why Python is slower compared to other programming languages like C++, Java, and JavaScript

Full Transcript

why python is slow this is the question that comes up from people who have worked with compile languages like java and c plus sometimes people also argue javascript is an interpreter language and still it is faster than python i asked this question to one of the members of python steering council python studying council is a committee of five people who decides the future direction of python language these are the creators of python language and i will quickly summarize what we discuss in that call in this video point number one is when you are saying python is slow are you using right module and right approach for example when you are doing heavy number crunching vector and matrix operation you should be using numpy and pandas here i am going to do a quick demo of comparing numpy performance with plain python list here i have created two big list hundred thousand elements each using plain python list and i am going to now divide this to list element by element so that i get price to earning ratio this gives 8.35 millisecond performance but if you i use numpy for the same thing you see i have created numpy arrays i get 94 microsecond which means numpy is 88 times faster so when it comes to big metrics and operations and vector operations numpy and pandas perform the best and that's the reason they are used heavily in machine learning you see that using numpy speeds of the performance and if you are using python list then it was not a python's problem it was your problem you are not aware about the right approach that you should be using in your program now the reason numpy's and pandas are faster is they underneath execute in c or c plus plus so python just provides a wrapper api you make like one line call underneath you get c plus plus performance and that's the reason um python is used so much in machine learning most of the people who are doing machine learning they use python they don't know don't use javascript or they don't use c plus plus so just think about it machine learning is so much computation intensive if python was slow why would people use it for machine learning point number two is let's take about plain python so if you are writing a program in plain python of course it's gonna be slower than compile languages like java and c plus for obvious reasons python is a high level language it gives you convenience rapid prototyping so to get that benefit you have to compromise on the speed now why javascript being an interpreted language is faster because think about google chrome for example javascript is built into a browser now google as a company wants people to use google chrome so google put so much money in making javascript faster javascript is a language specification they have this um v8 engine va the google chrome runs on a v8 javascript engine which is super fast so google puts tons of money in making that faster because they want people to use google chrome so when big companies like google is putting a lot of money into some language of course you will get performance whereas python yeah people are work putting money into it but no company has a proprietary python product like like google chrome so they contribute little bit so python doesn't get as much funding as javascript having said that there are a force being made to make the plain python performance better and you can listen to that whole conversation i'm going gonna put the link of that conversation with python council member in the video description below but overall if you're using the right set of libraries like numpy's and pandas you'll probably not have complaints about speed sometimes your program is slow is slow because you are not using the right design pattern or you are using some for loop unnecessarily so whenever you you think your program is the first try to analyze if there are any design problems in your code try to fix them then try to use the right set of libraries like numpas and pandas 90 to 95 of the time you will not have a complaint that python is low i hope this video helps with your question if you like this video give it a thumbs up if you have any other question post in the comment below

Original Description

Many times people argue that python is slow compared to C++ or JAVA. They even argue that look at Javascript, it is also an interpreted language and yet python is slower compared to Javascript. I asked this question to python steering council member, Pablo Galindo. This council is a group of 5 people who decide the future direction of python programming language. In this video I will quickly summarize the why python is slow? If you want to watch entire conversation where we discussed other topics as well than watch this video, Entire conversation: https://youtu.be/b23kMqp2M7A Part where we discussed python speed: https://youtu.be/b23kMqp2M7A?t=2022 Numpy as python list speed comparison code: https://github.com/codebasics/py/blob/master/numpy/numpy_vs_list_speed_comparison.ipynb Do you want to learn technology from me? Check https://codebasics.io/ for my affordable video courses. 🌎 Website: https://www.codebasics.io/ 🎥 Codebasics Hindi channel: https://www.youtube.com/channel/UCTmFBhuhMibVoSfYom1uXEg #️⃣ Social Media #️⃣ 🔗 Discord: https://discord.gg/r42Kbuk 📸 Instagram: https://www.instagram.com/codebasicshub/ 🔊 Facebook: https://www.facebook.com/codebasicshub 📱 Twitter: https://twitter.com/codebasicshub 📝 Linkedin (Personal): https://www.linkedin.com/in/dhavalsays/ 📝 Linkedin (Codebasics): https://www.linkedin.com/company/codebasics/ ❗❗ DISCLAIMER: All opinions expressed in this video are of my own and not that of my employers'.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from codebasics · codebasics · 0 of 60

← Previous Next →
1 Python Tutorial - 1. Install python on windows
Python Tutorial - 1. Install python on windows
codebasics
2 Python Tutorial - 2. Variables
Python Tutorial - 2. Variables
codebasics
3 Python Tutorial - 3. Numbers
Python Tutorial - 3. Numbers
codebasics
4 Python Tutorial - 4. Strings
Python Tutorial - 4. Strings
codebasics
5 Python Tutorial - 5. Lists
Python Tutorial - 5. Lists
codebasics
6 Python Tutorial - 6. Install PyCharm on Windows
Python Tutorial - 6. Install PyCharm on Windows
codebasics
7 PyCharm Tutorial - 7. Debug python code using PyCharm
PyCharm Tutorial - 7. Debug python code using PyCharm
codebasics
8 Python Tutorial -  8. If Statement
Python Tutorial - 8. If Statement
codebasics
9 Python Tutorial - 9. For loop
Python Tutorial - 9. For loop
codebasics
10 Python Tutorial -  10. Functions
Python Tutorial - 10. Functions
codebasics
11 Python Tutorial - 11. Dictionaries and Tuples
Python Tutorial - 11. Dictionaries and Tuples
codebasics
12 Python Tutorial - 12. Modules
Python Tutorial - 12. Modules
codebasics
13 Python Tutorial - 13. Reading/Writing Files
Python Tutorial - 13. Reading/Writing Files
codebasics
14 How to install Julia on Windows
How to install Julia on Windows
codebasics
15 Python Tutorial - 14. Working With JSON
Python Tutorial - 14. Working With JSON
codebasics
16 Julia Tutorial - 1. Variables
Julia Tutorial - 1. Variables
codebasics
17 Julia Tutorial - 2. Numbers
Julia Tutorial - 2. Numbers
codebasics
18 Python Tutorial - 15. if __name__ == "__main__"
Python Tutorial - 15. if __name__ == "__main__"
codebasics
19 Julia Tutorial - Why Should I Learn Julia Programming Language
Julia Tutorial - Why Should I Learn Julia Programming Language
codebasics
20 Python Tutorial  - 16. Exception Handling
Python Tutorial - 16. Exception Handling
codebasics
21 Julia Tutorial - 3. Complex and Rational Numbers
Julia Tutorial - 3. Complex and Rational Numbers
codebasics
22 Julia Tutorial - 4. Strings
Julia Tutorial - 4. Strings
codebasics
23 Python Tutorial -  17. Class and Objects
Python Tutorial - 17. Class and Objects
codebasics
24 Julia Tutorial - 5. Functions
Julia Tutorial - 5. Functions
codebasics
25 Julia Tutorial - 6. If Statement and Ternary Operator
Julia Tutorial - 6. If Statement and Ternary Operator
codebasics
26 Julia Tutorial - 7. For While Loop
Julia Tutorial - 7. For While Loop
codebasics
27 Python Tutorial  - 18. Inheritance
Python Tutorial - 18. Inheritance
codebasics
28 Julia Tutorial - 8. begin and (;) Compound Expressions
Julia Tutorial - 8. begin and (;) Compound Expressions
codebasics
29 Python Tutorial - 12.1 - Install Python Module (using pip)
Python Tutorial - 12.1 - Install Python Module (using pip)
codebasics
30 Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
codebasics
31 Julia Tutorial - 10. Exception Handling
Julia Tutorial - 10. Exception Handling
codebasics
32 Python Tutorial  - 19. Multiple Inheritance
Python Tutorial - 19. Multiple Inheritance
codebasics
33 Python Tutorial - 20. Raise Exception And Finally
Python Tutorial - 20. Raise Exception And Finally
codebasics
34 Python Tutorial - 21. Iterators
Python Tutorial - 21. Iterators
codebasics
35 Python Tutorial - 22. Generators
Python Tutorial - 22. Generators
codebasics
36 Python Tutorial - 23. List Set Dict Comprehensions
Python Tutorial - 23. List Set Dict Comprehensions
codebasics
37 Python Tutorial - 24. Sets and Frozen Sets
Python Tutorial - 24. Sets and Frozen Sets
codebasics
38 Python Tutorial - 25. Command line argument processing using argparse
Python Tutorial - 25. Command line argument processing using argparse
codebasics
39 Debugging Tips - What is bug and debugging?
Debugging Tips - What is bug and debugging?
codebasics
40 Debugging Tips - Conditional Breakpoint
Debugging Tips - Conditional Breakpoint
codebasics
41 Debugging Tips - Watches and Call Stack
Debugging Tips - Watches and Call Stack
codebasics
42 Python Tutorial - 26. Multithreading - Introduction
Python Tutorial - 26. Multithreading - Introduction
codebasics
43 Git Tutorial 3:  How To Install Git
Git Tutorial 3: How To Install Git
codebasics
44 Git Tutorial 1: What is git / What is version control system?
Git Tutorial 1: What is git / What is version control system?
codebasics
45 Git Tutorial 2 : What is Github? | github tutorial
Git Tutorial 2 : What is Github? | github tutorial
codebasics
46 Git Tutorial 4: Basic Commands: add, commit, push
Git Tutorial 4: Basic Commands: add, commit, push
codebasics
47 Git Tutorial 5: Undoing/Reverting/Resetting code changes
Git Tutorial 5: Undoing/Reverting/Resetting code changes
codebasics
48 Git Tutorial 6: Branches (Create, Merge, Delete a branch)
Git Tutorial 6: Branches (Create, Merge, Delete a branch)
codebasics
49 Git Github Tutorial 10: What is Pull Request?
Git Github Tutorial 10: What is Pull Request?
codebasics
50 Git Tutorial 7: What is HEAD?
Git Tutorial 7: What is HEAD?
codebasics
51 Git Tutorial 9: Diff and Merge using meld
Git Tutorial 9: Diff and Merge using meld
codebasics
52 Difference between Multiprocessing and Multithreading
Difference between Multiprocessing and Multithreading
codebasics
53 Python Tutorial - 27. Multiprocessing Introduction
Python Tutorial - 27. Multiprocessing Introduction
codebasics
54 Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
codebasics
55 Git Tutorial 8 - .gitignore file
Git Tutorial 8 - .gitignore file
codebasics
56 Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
codebasics
57 Python Tutorial - 30. Multiprocessing Lock
Python Tutorial - 30. Multiprocessing Lock
codebasics
58 Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
codebasics
59 What is code?
What is code?
codebasics
60 Python unit testing - pytest introduction
Python unit testing - pytest introduction
codebasics

Related Reads

📰
Your Vibe Code Has No Memory. DESIGN.md Fixes That.
Use a DESIGN.md file to give your AI agent design memory and maintain UI consistency across sessions
Dev.to AI
📰
From Pixel-Pushing to Full-Stack Closed Loop: The Future of Frontend & Designer Collaboration
Learn how to improve frontend and designer collaboration by adopting new tools and trends, increasing efficiency and reducing manual labor
Dev.to AI
📰
the vibe-coded portfolio / how to build one, 20+ examples, tips + tricks
Learn to build a vibe-coded portfolio, a product showcasing your UX design skills, with 20+ examples and tips
Medium · UX Design
📰
You’ve decided to become a product designer in 2026. What comes next?
Learn the next steps to become a product designer in 2026 and kickstart your career
Medium · UX Design
Up next
Free AI UX Design Course by Figma
The Cutting Edge School
Watch →