From 7b89fbb1c6f655cf2e69697575908542e4d197cf Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Sun, 5 Dec 2021 13:44:38 +0300 Subject: [PATCH 1/2] perf: drop the initial stack copy --- src/blib2to3/pgen2/parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blib2to3/pgen2/parse.py b/src/blib2to3/pgen2/parse.py index 792e8e66698..e5dad3ae766 100644 --- a/src/blib2to3/pgen2/parse.py +++ b/src/blib2to3/pgen2/parse.py @@ -53,7 +53,7 @@ def __init__(self, parser: "Parser", ilabels: List[int], context: Context) -> No self.context = context # not really matter self._dead_ilabels: Set[int] = set() - self._start_point = copy.deepcopy(self.parser.stack) + self._start_point = self.parser.stack self._points = {ilabel: copy.deepcopy(self._start_point) for ilabel in ilabels} @property From 39541536873e2970f2c754979b9e8f2187eac58e Mon Sep 17 00:00:00 2001 From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Sun, 5 Dec 2021 15:08:01 -0500 Subject: [PATCH 2/2] Add changelog --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 097725ec0be..434f80980a5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,6 +26,8 @@ - Fix styling of starred expressions inside `match` subject (#2667) - Fix parser error location on invalid syntax in a `match` statement (#2649) - Fix Python 3.10 support on platforms without ProcessPoolExecutor (#2631) +- Improve parsing performance on code that uses `match` under `--target-version py310` + up to ~50% (#2670) ### Packaging