When are .pyc files refreshed?

后端 未结 2 366
谎友^
谎友^ 2020-11-29 02:33

I understand that \".pyc\" files are compiled versions of the plain-text \".py\" files, created at runtime to make programs run faster. However I have observed a few things:

2条回答
  •  -上瘾入骨i
    2020-11-29 02:48

    The .pyc files are created (and possibly overwritten) only when that python file is imported by some other script. If the import is called, Python checks to see if the .pyc file's internal timestamp is not older than the corresponding .py file. If it is, it loads the .pyc; if it isn't or if the .pyc does not yet exist, Python compiles the .py file into a .pyc and loads it.

    What do you mean by "stricter checking"?

提交回复
热议问题