0

I know about .pyc files (compiled .py file) and difference between them:
difference between .py and .pyc


My question is:

  • Is there difference between runtime of .py and .pyc files or those benchmarks?
  • And is using .pyc instead of .py reliable ?

Thanks in advance.


Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150

2 Answers2

1

.pyc contains byte code which is essentially what the interpreter compiles the source code into.Generating byte code is essentially something that is done for optimisation by which way your code can be run directly without having to create an executable. This makes things faster.

Vishnu Kiran
  • 620
  • 7
  • 15
0

I think when you run a .py file, it takes few time for creating its .pyc file.

And when you straight run .pyc file does not need to take a time for creating .pyc file and then runtime of .py and .pyc files are the same.

Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150