pythonpyc

what is pycache folder in flask python?


I am working on a flask project.

and there is __pycache__ file under app> main with .pyc files.

What are these for?

and when I try to click on the .pyc file , it says the file is not displayed in the editor becuase it is either binary or uses an unsupported text encoding. what are the ways to open this file and see what is inside? Thank you.

Edit: I found what this file is for in other website

At the time when you run a program in python, the interpreter compiles it to bytecode first and after compilation interpreter stores it in the pycache folder. So when you look in there you will find a bunch of files sharing the names of the .py files in your project's folder, you will see that their extensions will be either .pyc or .pyo. These files are bytecode-compiled and optimized bytecode-compiled versions of your program's files, respectively.

pycache makes your program to start a little faster. When your scripts change, they will be recompiled, and if you delete the files or the whole folder and run your program again, they will reappear (unless you specifically suppress that behavior)

https://intellipaat.com/community/4278/what-is-pycache


Solution

  • .pyc files are compiled Python files written by the Python interpreter. Read here.