LearningPython

How Python Run:python ’s source code save in “.py”.the byte code save in “.pyc”.if you have compile a “.py” file ,it will build a “.pyc”file ,the next time when you rerun the “.py”file ,the.system will find if the “.py”file ’s timestamp is same as “.pyc”file ’s timestamp ,if is same ,it will cot compile again ,if not it will be compile again.and if you run the same “.py”file on the other python version next time ,it will also recompile the source code again.
?python’s traditional runtime execution model:source code you type is translated to byte code, which is then run by the python virtual machine.your code is automatically compiled, but then it is interpreted.
?the PVM is not a separate program, and it need not to be installed by itself.in fact ,the PVM is just a big code loop that iterates through your byte code instructions, one by one to carry out their operations.
?at a more fundamental level, keep in mind that all we really have in python is “runtime”,there is. no initial “compile-time” phase at all ,and everything happens as the program is running.although we know the “source code”will change to”byte code”and then the “PVM”,but actually we do not truly see what the “python interpreter”do these, what we can only see is the “python interpreter ”run the program the programmer type.
?How to debug:1.do nothing(there will be error message by python itself);2.insert “print”statements(remember to add “#”before you ship your code, this method is very fast ) 3.use IDE GUI debuggers;
4.use the pdb command-line debugger.

猜你喜欢

转载自blog.csdn.net/qq_40590753/article/details/82735939