In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What are the five actual steps of Python code execution? I believe many inexperienced people are at a loss about this. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Python executes the code through the following process:
1. Tokenizer performs lexical analysis and decomposes the source program into Token.
2. Parser creates CST based on Token
3. CST is converted to AST
4. AST is compiled into bytecode
5. Execution bytecode
When executing Python code, for example, if the code is stored in a file, Python will call the PyParser_ASTFromFile function to convert the code contents of the file to AST:
Mod_ty
PyParser_ASTFromFile (FILE * fp, const char * filename
Int start, char * ps1
Char * ps2, PyCompilerFlags * flags, int * errcode
PyArena * arena)
{
Mod_ty mod
Perrdetail err
Node * n = PyParser_ParseFileFlags (fp, filename
& _ PyParser_Grammar
Start, ps1, ps2, & err, PARSER_FLAGS (flags))
If (n) {
Mod = PyAST_FromNode (n, flags, filename, arena); PyNode_Free (n)
Return mod
}
Else {
Err_input & err)
If (errcode)
* errerrcode = err.error
Return NULL
}
}
In
PyParser_ParseFileFlags
After the file is converted to CST in the Python execution code, the PyAST_FromNode function converts CST to AST. This function is defined in include\ ast.h:
PyAPI_FUNC (mod_ty) PyAST_FromNode (const node *, PyCompilerFlags * flags, const char *, PyArena *); after reading the above, have you mastered what are the five steps of Python's actual execution of the code? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.