Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why do people say python is slow because it is interpreted? It has .pyc files [closed]

Why don't people just use the compiled python file whenever they need optimization? Then the code won't have to be interpereted then compiled.

Is there something I am missing? It seems to me like a simple problem.

like image 576
user3571278 Avatar asked Jul 02 '15 17:07

user3571278


People also ask

Are PYC files faster than py files?

pyo file than when it is read from a . py file; the only thing that's faster about . pyc or . pyo files is the speed with which they are loaded.

What is .PYC file in Python?

pyc files are created by the Python interpreter when a . py file is imported. They contain the "compiled bytecode" of the imported module/program so that the "translation" from source code to bytecode (which only needs to be done once) can be skipped on subsequent imports if the . pyc is newer than the corresponding .

What is the difference between .py and .PYC files?

py files contain the source code of a program. Whereas, . pyc file contains the bytecode of your program.

Does PYC run faster?

A program doesn't run any faster when it is read from a ". pyc" or ". pyo" file than when it is read from a ". py" file; the only thing that's faster about ".


1 Answers

I believe this is enough to correct your misunderstanding.

A program doesn’t run any faster when it is read from a .pyc or .pyo file than when it is read from a .py file; the only thing that’s faster about .pyc or .pyo files is the speed with which they are loaded.

source : https://docs.python.org/2/tutorial/modules.html#packages

like image 56
bubakazouba Avatar answered Oct 05 '22 22:10

bubakazouba