Why python code runs slowly as compare to other programming languages? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why python code runs slowly as compare to other programming languages?

15th Jul 2020, 7:31 AM
Omkar Kamat
Omkar Kamat - avatar
10 Answers
+ 4
codemonkey python is not compiled to machine code : it is compiled down to python bytecode, that is then interpreted by the python interpreter. Another reason why Python is slow is that you can modify this bytecode at runtime...
15th Jul 2020, 7:54 AM
Théophile
Théophile - avatar
+ 4
It's an interpreted, dynamically typed language.
15th Jul 2020, 9:18 PM
Sonic
Sonic - avatar
+ 3
It depends upon your IDE (Itergreted development environment).And more thing,in sololearn app because of a huge number of users of python it works just a little slower. I hope it will let you understand....
15th Jul 2020, 7:37 AM
Akash Patel
Akash Patel - avatar
+ 1
Python is slow for some reasons : - it is interpreted (at least for the CPython implementation, which is the official interpreter) - python isn't strongly typed (you never explicitly write the types of the variable. And type annotations are simply ignored). That's a big disadvantage because each time you manipulate a variable, python must perform some type checking - python is an incredibly complex language, that is not designed to be fast anyway
15th Jul 2020, 7:42 AM
Théophile
Théophile - avatar
+ 1
Såñtösh Màràvi(Challenge Me On JUMP_LINK__&&__Python__&&__JUMP_LINK) That doesn't mean anything. That is not because a langage seems more complex that it is faster. In rust : fn main() { println!("Hello"); } And Rust is as fast as c++. And Rust is with c and c++ the three big system programming langages. Please never judge the complexity of a code to know if it is faster or not. Have you ever heard about zero-cost abstractions? (like iterators in Rust)
15th Jul 2020, 8:01 AM
Théophile
Théophile - avatar
+ 1
Granger actually, it doesn't help python, since you can do : a: int = "hello" Here, the only things it does is updating the __annotations__ dict. a: int = "hello" print(globals()) # you will see : # "__annotations__" : {"a": <class 'int'>} But python ignores this annotations. This are simply annotations for the développer, and not for the interpreter 😁.
15th Jul 2020, 9:19 AM
Théophile
Théophile - avatar
+ 1
Since the python is dynamically typed language, compiler don't have ability to handle dynamic data types that are assigned to a same variable. That's why we need the program that run on runtime i.e. interpreter in order to dynamically change the memory location. That's why the python is slow.
16th Jul 2020, 8:40 AM
Crazy_programmer
Crazy_programmer - avatar
+ 1
Which of program langage is well python or C,C++C# or another language?
16th Jul 2020, 7:25 PM
Odiljon Usmonov
0
It is very simple language that have sort syntax . And easy codes as compared to another languages. That's why it takes more time to convert man- Made code to machine code . Many languages has more syntax than python. Let's see with e.g👇👇 In python print ("hello ") Whereas in c++ #include <iostream> using namespace std; int main() { cout << "Hello"; return 0; } so lastly we can see in c++ has more syntax so computer easily converted that language .
15th Jul 2020, 7:41 AM
Sâñtôsh
Sâñtôsh - avatar
0
Odiljon Usmonov all programming language are well but python is simple as compare to other programming languages.
17th Jul 2020, 3:06 AM
Omkar Kamat
Omkar Kamat - avatar