When you run a program in python, the interpreter compiles it to bytecode first (this is an oversimplification) and stores it in the
__pycache__ folder. If you look in there you will find a bunch of files sharing the names of the .py files in your project’s folder, only their extensions will be either .pyc or .pyo. These are bytecode-compiled and optimized bytecode-compiled versions of your program’s files, respectively.
As a programmer, you can largely just ignore it… All it does is make your program 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)
If you are using cpython (which is the most common, as it’s the reference implementation) and you don’t want that folder, then you can suppress it by starting the interpreter with the -B flag, for example
python -B foo.py
Another option, as noted by tcaswell, is to set the environment variable
PYTHONDONTWRITEBYTECODE to any value (according to python’s man page, any “non-empty string”).
__pycache__ is a folder containing Python 3 bytecode compiled and ready to be executed.
Don’t bother deleting these files nor suppress creation. It’s pointless and will actually hurt performance.
Python programmers usually ignore bytecode. Indeed
*.pyc are common lines to see in
.gitignore files. Bytecode is not meant for distribution and can be disassembled using
A __pycache__folder is created when you use the line
or try to get information from another file you have created. This makes it a little faster when running the program your second time to open the other file.