Skip to content

Docs: Design virtual objects, refcount elision and region allocation (N-12) - #144

Merged
b-re-w merged 3 commits into
developfrom
feat/tp-virtual-objects
Oct 3, 2026
Merged

b-re-w merged 3 commits into
developfrom
feat/tp-virtual-objects

Conversation

@b-re-w

@b-re-w b-re-w commented Oct 3, 2026

Copy link
Copy Markdown
Member

Refs #143 (design only; implementation waits for the decision below).

Documentation added: SPEC N-12 (Status: planned (design)) and design §4.3.4.

  • Identity is defined as: every execution of compiled code is indistinguishable from some valid CPython execution.
  • Virtual objects (partial escape analysis plus deferred materialisation) apply to N-11 classes without __del__ and without __weakref__. They are materialised before every observation point, in allocation order. The observation points include any unknown call while the object is alive, because gc.get_objects() and tracemalloc see objects that were never passed. is, type and isinstance are decided statically.
  • Refcount elision applies only with a keeping reference and no unknown code in between, so every observable refcount is exact.
  • Regions hold virtual objects only (never real PyObjects) and are tied to the innermost scope that bounds their lifetime. A failed region allocation raises MemoryError at the CPython allocation point.
  • The verifier must prove four properties. Anything unproved compiles as N-11. The differential and mutation tests are listed.

Needs a user decision (via the leader), §4.3.4 마.1: is garbage-collection timing part of the identity? Not allocating moves collections, and with them the finalisers of unrelated cyclic garbage.

  • Keeping the timing needs synthetic allocation counts and running scheduled collections in place, through CPython-internal structures.
  • The language reference leaves the timing to the implementation, and CPython 3.14's incremental GC already changed it.

Pre-existing gaps found while writing this (separate issues, not caused by N-12):

Text follows the no em-dash rule.

@b-re-w
b-re-w merged commit 7e1bb09 into develop Oct 3, 2026
5 checks passed
@b-re-w
b-re-w deleted the feat/tp-virtual-objects branch October 3, 2026 15:54
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