bpo-43754: Eliminate bindings for partial pattern matches (GH-25229)

diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py
index 1f80fb4..8a273be 100644
--- a/Lib/test/test_patma.py
+++ b/Lib/test/test_patma.py
@@ -2905,6 +2905,79 @@ def test_patma_288(self):
                 pass
         """)
 
+    def test_patma_289(self):
+        x = {"y": 1}
+        match x:
+            case {"y": (0 as y) | (1 as y)}:
+                z = 0
+        self.assertEqual(x, {"y": 1})
+        self.assertEqual(y, 1)
+        self.assertEqual(z, 0)
+
+    @no_perf
+    def test_patma_290(self):
+        self.assert_syntax_error("""
+        match ...:
+            case [a, [b] | [c] | [d]]:
+                pass
+        """)
+
+    @no_perf
+    def test_patma_291(self):
+        # Hunting for leaks using -R doesn't catch leaks in the compiler itself,
+        # just the code under test. This test ensures that if there are leaks in
+        # the pattern compiler, those runs will fail:
+        with open(__file__) as file:
+            compile(file.read(), __file__, "exec")
+
+    def test_patma_292(self):
+        def f(x):
+            match x:
+                case ((a, b, c, d, e, f, g, h, i, 9) |
+                      (h, g, i, a, b, d, e, c, f, 10) |
+                      (g, b, a, c, d, -5, e, h, i, f) |
+                      (-1, d, f, b, g, e, i, a, h, c)):
+                    w = 0
+            out = locals()
+            del out["x"]
+            return out
+        alts = [
+            dict(a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8, w=0),
+            dict(h=1, g=2, i=3, a=4, b=5, d=6, e=7, c=8, f=9, w=0),
+            dict(g=0, b=-1, a=-2, c=-3, d=-4, e=-6, h=-7, i=-8, f=-9, w=0),
+            dict(d=-2, f=-3, b=-4, g=-5, e=-6, i=-7, a=-8, h=-9, c=-10, w=0),
+            dict(),
+        ]
+        self.assertEqual(f(range(10)), alts[0])
+        self.assertEqual(f(range(1, 11)), alts[1])
+        self.assertEqual(f(range(0, -10, -1)), alts[2])
+        self.assertEqual(f(range(-1, -11, -1)), alts[3])
+        self.assertEqual(f(range(10, 20)), alts[4])
+
+    def test_patma_293(self):
+        def f(x):
+            match x:
+                case [y, (a, b, c, d, e, f, g, h, i, 9) |
+                         (h, g, i, a, b, d, e, c, f, 10) |
+                         (g, b, a, c, d, -5, e, h, i, f) |
+                         (-1, d, f, b, g, e, i, a, h, c), z]:
+                    w = 0
+            out = locals()
+            del out["x"]
+            return out
+        alts = [
+            dict(a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8, w=0, y=False, z=True),
+            dict(h=1, g=2, i=3, a=4, b=5, d=6, e=7, c=8, f=9, w=0, y=False, z=True),
+            dict(g=0, b=-1, a=-2, c=-3, d=-4, e=-6, h=-7, i=-8, f=-9, w=0, y=False, z=True),
+            dict(d=-2, f=-3, b=-4, g=-5, e=-6, i=-7, a=-8, h=-9, c=-10, w=0, y=False, z=True),
+            dict(),
+        ]
+        self.assertEqual(f((False, range(10), True)), alts[0])
+        self.assertEqual(f((False, range(1, 11), True)), alts[1])
+        self.assertEqual(f((False, range(0, -10, -1), True)), alts[2])
+        self.assertEqual(f((False, range(-1, -11, -1), True)), alts[3])
+        self.assertEqual(f((False, range(10, 20), True)), alts[4])
+
 
 class PerfPatma(TestPatma):
 
@@ -2936,7 +3009,8 @@ def setUpClass():
 
 
 """
-sudo ./python -m pyperf system tune && \
-     ./python -m pyperf timeit --rigorous --setup "from test.test_patma import PerfPatma; p = PerfPatma()" "p.run_perf()"; \
-sudo ./python -m pyperf system reset
+# From inside venv pointing to this Python, with pyperf installed:
+sudo $(which python) -m pyperf system tune && \
+     $(which python) -m pyperf timeit --rigorous --setup "from test.test_patma import PerfPatma; p = PerfPatma()" "p.run_perf()"; \
+sudo $(which python) -m pyperf system reset
 """