Why python code runs slowly as compare to other programming languages? | SoloLearn: Learn to code for FREE!

+2

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

7/15/2020 7:31:24 AM

ok ok [ Omkar ]

13 Answers

New Answer

+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...

+3

It's an interpreted, dynamically typed language.

+3

Odiljon Usmonov, You can do AI with Python, It works very well with him) But it is most likely just for this purpose, because other things, for example, games, cannot be made good on it. Well, or for the backend (Django). And so, C# for software and desktop applications, C++ for games, software, and C is now rarely used, it is more like a base language in which many other languages ​​are created

+2

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....

+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

+1

Såñtösh Màràvi(Challenge Me On Python) 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)

+1

Théophile, we can help python by specifying the variable type each time :>

+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 😁.

+1

Théophile, oh, ok 😂🗿

+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.

+1

Which of program langage is well python or C,C++C# or another language?

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 .

0

Odiljon Usmonov all programming language are well but python is simple as compare to other programming languages.