# SPDX-License-Identifier: MIT """PyPy keeps an instance with 80 or more attributes as a dict, and the hot loop then runs about three times slower (the family's PyPy rule; a2600-python's tests/test_pypy_layout.py).""" import pytest from w65c02_python import G65SC02, R65C02, W65C02S, Lynx2Cell from w65c02_python.debug import W65C02Session @pytest.mark.parametrize("row", [W65C02S, R65C02, G65SC02, Lynx2Cell], ids=lambda row: row.__name__) def test_the_cpu_stays_under_eighty_attributes(row) -> None: memory = bytearray(0x10000) cpu = row(memory.__getitem__, memory.__setitem__) cpu.request_reset() cpu.request_maskable_interrupt() for _ in range(4): cpu.step() session = W65C02Session(cpu, track_accesses=True) # the debugger replaces the bus callables session.step() assert len(vars(cpu)) < 80, sorted(vars(cpu)) assert len(vars(cpu)) < 40 # room for a board's subclass