Home > News content

The father of Python considers refactoring the Python interpreter

via:博客园     time:2019/7/27 12:00:43     readed:159

Author: A fan

IT House July 26th Recently, Python's father Gido · Van Rossum published an article called "PEG Parser", Van Rossum said he is considering using PEG Parser instead of the existing class LL (1) Parser (named pgen) to refactor the Python interpreter.

Van Rossum said that the current pgen limits the freedom of Python syntax, making some grammars difficult to implement, and making the current syntax tree not clean enough, which affects the meaning of the syntax tree to a certain extent, and does not best reflect the designer's intention.

The PEG syntax interpreter loads all the code at once when parsing the syntax, so the interpreter can judge the semantics of the grammar based on the symbols at any position. The current LL (1) Parse parsing grammar only detects a symbol forward to guess the semantics, which leads to the ambiguous representation of some grammars, which limits the grammar definition of the Python language. Of course, loading all the code at once means that PEG Parser needs more memory to run.

In response to the above situation, the Python interpreter can't handle the problem, only the Python team will continue to add "exceptions" to the code to handle these edge cases. Van Rossum said that when Python first came out, the memory was still very expensive. LL (1) Parse was very suitable, but now the memory price has been greatly reduced, so it is more appropriate to refactor Python with PEG Parser.

Van Rossum said that refactoring the Python interpreter with PEG Parser does not have a grammatical effect, because the underlying refactoring does not affect Python syntax.

China IT News APP

Download China IT News APP

Please rate this news

The average score will be displayed after you score.

Post comment

Do not see clearly? Click for a new code.

User comments