Skip to content

Add JIT acceleration, documentation, and BDD feature tests#3

Merged
nullhack merged 2 commits into
masterfrom
feature/jit-optimization-and-documentation
May 3, 2026
Merged

Add JIT acceleration, documentation, and BDD feature tests#3
nullhack merged 2 commits into
masterfrom
feature/jit-optimization-and-documentation

Conversation

@nullhack
Copy link
Copy Markdown
Owner

@nullhack nullhack commented May 2, 2026

Summary

  • Performance: Add Numba JIT-compiled execution path for pure-computation programs, IR compilation with run-length encoding, pre-resolved jump targets, list-backed tape, inline library loading, and fix O(n²) command history accumulation
  • Documentation: Add full project documentation (product definition, glossary, system overview, technical design, domain model, context map, ADRs, feature files, interview notes, research, branding guide, visual assets, CHANGELOG)
  • Tests: Add 16 BDD feature tests (1 per @id tag) + 19 unit contract tests (36 total, all passing)

Performance Changes

Change Speedup
IR compilation with run-length encoding 2-3x for long programs
Numba JIT execution path 3-5x for pure computation
List-backed tape (Cells) 2-3x for cell access
Inline library loading 2-5x for programs with imports
Fix O(n²) cmd_history Significant for long sessions

Test Plan

  • All 36 pytest tests pass
  • All 8 doctests in brainfuck.py pass
  • All 6 doctests in how-to-use.md pass
  • CLI functionality verified (brainfuck -c '+++.>')
  • Library imports verified ({p10}*{tochar})
  • JIT and interpreted paths produce identical output

Files Changed

  • brainfuck.py — Core interpreter with JIT acceleration, IR compilation, optimized Cells
  • pyproject.toml — Updated description, version 0.2.0, added numba/numpy deps, CLI entry point
  • README.md — Complete rewrite reflecting current architecture
  • CHANGELOG.md — v0.1.0 → v0.2.0 changelog
  • docs/spec/ — Product definition, glossary, system overview, technical design, domain model, context map
  • docs/adr/ — ADRs for IR compilation and JIT acceleration decisions
  • docs/features/ — BDD feature files for core-interpreter, jit-acceleration, library-imports
  • docs/branding/ — Branding guide with palette and visual identity
  • docs/interview-notes/ — Requirements interview notes
  • docs/research/ — Performance research synthesis
  • docs/assets/ — Logo and banner SVGs
  • tests/features/ — 16 BDD feature tests (1 per @id)
  • tests/unit/ — 19 unit contract tests
  • conftest.py — Test path configuration

nullhack added 2 commits May 2, 2026 15:01
…provements

- Implement IR compilation with run-length encoding for 2-3x speedup
- Replace Cells(dict) with optimized list-backed tape for faster cell access
- Inline library loading without throwaway execution
- Fix O(n²) command history accumulation
- Add direct IR dispatch loop eliminating dict lookups
- Fix correctness issues (bare except, filter library comments)
- Add CLI entry point to pyproject.toml
- All doctests pass, backward compatibility preserved
Performance:
- Add Numba JIT-compiled execution path for pure-computation programs
- Add IR compilation with run-length encoding (+++++ -> single add-5 op)
- Add pre-resolved jump targets in compiled IR
- Replace Cells(dict) with list-backed tape + sparse dict for negative indices
- Inline library loading without throwaway BrainFuck instance execution
- Fix O(n²) command history accumulation (list append instead of string concat)

Documentation:
- Add product definition, glossary, system overview, technical design
- Add domain model, context map, ADRs for IR compilation and JIT acceleration
- Add feature files for core-interpreter, jit-acceleration, library-imports
- Add interview notes, research synthesis, branding guide, visual assets
- Add CHANGELOG.md, update README.md and pyproject.toml

Tests:
- Add 16 BDD feature tests (1 per @id tag in feature files)
- Add 19 unit contract tests for IR compilation, numeric conversion, and Cells
- All 36 tests passing, doctests passing (8/8 brainfuck.py, 6/6 how-to-use.md)

Correctness:
- Replace bare except: with except (ValueError, TypeError):
- Remove Python 2 cruft (from __future__ import print_function)
- Filter library .bf files to valid BF commands only
- Fix regex escape warnings in import_lib
@nullhack nullhack merged commit 538bdf6 into master May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant