Δεν έχει σημασία που το δοκίμασες και δεν δούλεψε αυτό συμβαίνει και σε εμένα συνέχεια
Τελικά πάντα αποδυκνυέται ότι κάπου εμείς κάνουμε λάθος και όχι τα βιβλία η το documentation.
Το παρακάτω κομμάτι εξηγεί πως δουλεύει το compile
Αφού σε ενδιαφέρει το θέμα βρες το βιβλίο και ρίξε μια ματιά αφιερώνει κάποια κεφάλαια μόνο σε αυτό το θέμα.
2. Compile It (Maybe)
After finding a source code file that matches an import statement by traversing the
module search path, Python next compiles it to byte code, if necessary. We discussed
byte code briefly in Chapter 2, but it’s a bit richer than explained there. During an
import operation Python checks both file modification times and the byte code’s Python
version number to decide how to proceed. The former uses file “timestamps,” and the
latter uses either a “magic” number embedded in the byte code or a filename, depending
on the Python release being used. This step chooses an action as follows:
Compile
If the byte code file is older than the source file (i.e., if you’ve changed the source)
or was created by a different Python version, Python automatically regenerates the
byte code when the program is run.
As discussed ahead, this model is modified somewhat in Python 3.2 and later—
byte code files are segregated in a __pycache__ subdirectory and named with their
Python version to avoid contention and recompiles when multiple Pythons are
installed. This obviates the need to check version numbers in the byte code, but
the timestamp check is still used to detect changes in the source.
Don’t compile
If, on the other hand, Python finds a .pyc byte code file that is not older than the
corresponding .py source file and was created by the same Python version, it skips
the source-to-byte-code compile step.
In addition, if Python finds only a byte code file on the search path and no source,
it simply loads the byte code directly; this means you can ship a program as just
byte code files and avoid sending source. In other words, the compile step is bypassed
if possible to speed program startup.
Notice that compilation happens when a file is being imported. Because of this, you
will not usually see a .pyc byte code file for the top-level file of your program, unless it
is also imported elsewhere—only imported files leave behind .pyc files on your machine.
The byte code of top-level files is used internally and discarded; byte code of
imported files is saved in files to speed future imports.
Top-level files are often designed to be executed directly and not imported at all. Later,
we’ll see that it is possible to design a file that serves both as the top-level code of a
program and as a module of tools to be imported. Such a file may be both executed
and imported, and thus does generate a .pyc. To learn how this works, watch for the
discussion of the special __name__ attribute and __main__ in Chapter 25.