Cache parsed components for 10x faster startup (2s → 200ms)

- Fix O(n²) postprocessing: compute_all_deps/io_refs/hash were called
  per-file (92x for sx app). Now deferred to single finalize_components()
  call after all files load.
- Add pickle cache in shared/sx/.cache/ keyed by file mtimes+sizes.
  Cache stores fully-processed Component/Island/Macro objects with deps,
  io_refs, and css_classes pre-computed. Closures stripped before pickle,
  rebuilt from global env after restore.
- Smart finalization: cached loads skip deps/io_refs recomputation
  (already in pickle), only recompute component hash.
- Fix ~sx-header → ~layouts/header ref in docs-content.sx

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 23:54:38 +00:00
parent bc1ea0128f
commit 100450772f
5 changed files with 224 additions and 42 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
__pycache__/
*.pyc
*.pyo
shared/sx/.cache/
.env
node_modules/
*.egg-info/