GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — instruction CACHE by youknowone · Pull Request #7251 · RustPython/RustPython

instruction CACHE #7251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
youknowone merged 4 commits into RustPython:main from youknowone:cache-inst
Mar 1, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

instruction CACHE #7251

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
fd9787f
Emit CACHE code units in bytecode to match CPython 3.14
youknowone Feb 27, 2026
f68f7ef
Use relative jump offsets and fix bytecode layout
youknowone Feb 27, 2026
ccc95f6
Align CPython 3.14 LOAD_GLOBAL null-bit and RERAISE semantics
youknowone Feb 28, 2026
b28fc61
Remove redundant CPython-referencing comments
youknowone Mar 1, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

69 changes: 69 additions & 0 deletions 69 Lib/opcode.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,75 @@
hascompare = [opmap["COMPARE_OP"]]

_cache_format = {
"LOAD_GLOBAL": {
"counter": 1,
"index": 1,
"module_keys_version": 1,
"builtin_keys_version": 1,
},
"BINARY_OP": {
"counter": 1,
"descr": 4,
},
"UNPACK_SEQUENCE": {
"counter": 1,
},
"COMPARE_OP": {
"counter": 1,
},
"CONTAINS_OP": {
"counter": 1,
},
"FOR_ITER": {
"counter": 1,
},
"LOAD_SUPER_ATTR": {
"counter": 1,
},
"LOAD_ATTR": {
"counter": 1,
"version": 2,
"keys_version": 2,
"descr": 4,
},
"STORE_ATTR": {
"counter": 1,
"version": 2,
"index": 1,
},
"CALL": {
"counter": 1,
"func_version": 2,
},
"CALL_KW": {
"counter": 1,
"func_version": 2,
},
"STORE_SUBSCR": {
"counter": 1,
},
"SEND": {
"counter": 1,
},
"JUMP_BACKWARD": {
"counter": 1,
},
"TO_BOOL": {
"counter": 1,
"version": 2,
},
"POP_JUMP_IF_TRUE": {
"counter": 1,
},
"POP_JUMP_IF_FALSE": {
"counter": 1,
},
"POP_JUMP_IF_NONE": {
"counter": 1,
},
"POP_JUMP_IF_NOT_NONE": {
"counter": 1,
},
}

_inline_cache_entries = {
Expand Down
3 changes: 0 additions & 3 deletions 3 Lib/test/test_dis.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,6 @@ def f(opcode, oparg, offset, *init_args):
def get_instructions(self, code):
return dis._get_instructions_bytes(code)

@unittest.expectedFailure # TODO: RUSTPYTHON; no inline caches
def test_start_offset(self):
# When no extended args are present,
# start_offset should be equal to offset
Expand Down Expand Up @@ -2289,7 +2288,6 @@ def last_item(iterable):
self.assertEqual(14, instructions[6].offset)
self.assertEqual(8, instructions[6].start_offset)

@unittest.expectedFailure # TODO: RUSTPYTHON; no inline caches
def test_cache_offset_and_end_offset(self):
code = bytes([
opcode.opmap["LOAD_GLOBAL"], 0x01,
Expand Down Expand Up @@ -2588,7 +2586,6 @@ def f():
with contextlib.redirect_stderr(io.StringIO()):
_ = self.invoke_dis('--unknown')

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_show_cache(self):
# test 'python -m dis -C/--show-caches'
source = 'print()'
Expand Down
7 changes: 0 additions & 7 deletions 7 Lib/test/test_inspect/test_inspect.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,6 @@ def function():
_global_ref = object()
class TestGetClosureVars(unittest.TestCase):

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[132 chars]={'print': <built-in function print>}, unbound=set()) != Closu[132 chars]={'print': <built-in function print>}, unbound={'unbound_ref'})
def test_name_resolution(self):
# Basic test of the 4 different resolution mechanisms
def f(nonlocal_ref):
Expand All @@ -2036,7 +2035,6 @@ def g(local_ref):
builtin_vars, unbound_names)
self.assertEqual(inspect.getclosurevars(f(_arg)), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[132 chars]={'print': <built-in function print>}, unbound=set()) != Closu[132 chars]={'print': <built-in function print>}, unbound={'unbound_ref'})
def test_generator_closure(self):
def f(nonlocal_ref):
def g(local_ref):
Expand All @@ -2052,7 +2050,6 @@ def g(local_ref):
builtin_vars, unbound_names)
self.assertEqual(inspect.getclosurevars(f(_arg)), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[132 chars]={'print': <built-in function print>}, unbound=set()) != Closu[132 chars]={'print': <built-in function print>}, unbound={'unbound_ref'})
def test_method_closure(self):
class C:
def f(self, nonlocal_ref):
Expand All @@ -2068,7 +2065,6 @@ def g(local_ref):
builtin_vars, unbound_names)
self.assertEqual(inspect.getclosurevars(C().f(_arg)), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[139 chars]als={}, builtins={'print': <built-in function [18 chars]et()) != Closu[139 chars]als={'_global_ref': <object object at 0xa4ffee[73 chars]ef'})
def test_attribute_same_name_as_global_var(self):
class C:
_global_ref = object()
Expand Down Expand Up @@ -2138,21 +2134,18 @@ def _private_globals(self):
exec(code, ns)
return ns["f"], ns

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[34 chars]uiltins={'print': <built-in function print>}, unbound=set()) != Closu[34 chars]uiltins={'print': <built-in function print>}, unbound={'path'})
def test_builtins_fallback(self):
f, ns = self._private_globals()
ns.pop("__builtins__", None)
expected = inspect.ClosureVars({}, {}, {"print":print}, {"path"})
self.assertEqual(inspect.getclosurevars(f), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: ClosureVars(nonlocals={}, globals={}, builtins={}, unbound={'print'}) != ClosureVars(nonlocals={}, globals={}, builtins={'path': 1}, unbound={'print'})
def test_builtins_as_dict(self):
f, ns = self._private_globals()
ns["__builtins__"] = {"path":1}
expected = inspect.ClosureVars({}, {}, {"path":1}, {"print"})
self.assertEqual(inspect.getclosurevars(f), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[38 chars]ins={}, unbound={'print'}) != Closu[38 chars]ins={'path': <module 'posixpath' from '/Users/[79 chars]nt'})
def test_builtins_as_module(self):
f, ns = self._private_globals()
ns["__builtins__"] = os
Expand Down
4 changes: 0 additions & 4 deletions 4 Lib/test/test_monitoring.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,6 @@ def func1():
('instruction', 'func1', 16),
('line', 'get_events', 11)])

@unittest.expectedFailure # TODO: RUSTPYTHON; - instruction offsets differ from CPython
def test_c_call(self):

def func2():
Expand Down Expand Up @@ -1672,7 +1671,6 @@ def func():
('return', 'func', None),
('line', 'get_events', 11)])

@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
def test_while_offset_consistency(self):

def foo(n=0):
Expand All @@ -1690,7 +1688,6 @@ def foo(n=0):
in_loop,
exit_loop])

@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
def test_async_for(self):

def func():
Expand Down Expand Up @@ -2126,7 +2123,6 @@ def test_get_local_events_uninitialized(self):

class TestRegressions(MonitoringTestBase, unittest.TestCase):

@unittest.expectedFailure # TODO: RUSTPYTHON; + inner
def test_105162(self):
caught = None

Expand Down
1 change: 0 additions & 1 deletion 1 Lib/test/test_peepholer.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ def f():
self.check_jump_targets(f)
self.check_lnotab(f)

@unittest.expectedFailure # TODO: RUSTPYTHON; KeyError: 44
def test_elim_jump_to_uncond_jump3(self):
# Intentionally use two-line expressions to test issue37213.
# POP_JUMP_IF_FALSE to POP_JUMP_IF_FALSE --> POP_JUMP_IF_FALSE to non-jump
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.