computronium
computronium

Reputation: 447

Why doesn't Python save byte code files for top level scripting files?

Python only saves .pyc files for code files which are being imported and not for top level script files. Why is this? Also, aren't the main source files compiled to byte code at all?

Upvotes: 0

Views: 408

Answers (1)

Cerenia
Cerenia

Reputation: 147

This has been asked before: Why does Python only save the bytecode for a script if it is imported?

A discussion about the intricacies of the various implementations of python execution: stackoverflow.com/questions/2998215/…

General concept for beginners to look up:

Python is generally executed through an interpreter, and the typical compilation process known from languages like C++ happens in the background and often at runtime. Have a look at this link for a more detailed explanation on compilation vs. interpretation: https://medium.com/@DHGorman/a-crash-course-in-interpreted-vs-compiled-languages-5531978930b6

Upvotes: 1

Related Questions