0

Why was .pyc file created?

I created a file KingKong.py: def KingKong(): print("Kingkong kingkong kingkong!") input("King?") print("Kong!") if __name__ == "__main__": print("Sorry") Then I executed Kong.py: import KingKong KingKong.KingKong() But why was KingKong.cpython-36.pyc created with text: 3 ��<[��@sdd�Zedkred�dS)cCstd�td�td�dS)NzKingkong kingkong kingkong!zKing?zKong!)�print�input�rr�0/storage/emulated/0/S/Python_project/KingKong.py�KingKongsr�__main__ZSorryN)r�__name__rrrrr�<module>s

4th Jul 2018, 5:02 PM
Seb TheS
Seb TheS - avatar
3 Answers
+ 6
Python automatically compiles your script to compiled code, so called byte code, before running it. When a module is imported for the first time, or when the source is more recent than the current compiled file, a .pyc file containing the compiled code will usually be created in the same directory as the .py file. http://effbot.org/pyfaq/how-do-i-create-a-pyc-file.htm
4th Jul 2018, 5:14 PM
Agent
Agent - avatar
+ 1
.pyc file is created on the first run and contains a bytecode: https://docs.python.org/3.5/glossary.html#term-bytecode The structure of the bytecode may depend on interpreter used to run python code.
4th Jul 2018, 5:22 PM
Fitz
Fitz - avatar
+ 1
you can delete them no worries, they will spawn when needed
4th Jul 2018, 5:25 PM
Qwertiony
Qwertiony - avatar