CONVERSION REFERENCE

Containers and records

PyCForge admits fixed, local data shapes whose capacity, representation, access, and lifetime can be proved before C is rendered.

Fixed homogeneous containers

Lists, tuples, dictionaries, and admitted sets are function-local, fixed, automatic-storage conversion forms. Capacity is 1–64 elements. A binding is assigned exactly once directly in a function body and may be used only through a proved operation documented below.

Lists and tuples

def pick() -> int:
    values = [10, 20, 30]
    return values[-1]

Sets and membership — new in 1.0.1

def is_priority(value: int) -> bool:
    priorities = {1, 4, 9}
    return value in priorities

def is_other(value: int) -> bool:
    priorities = {1, 4, 9}
    return value not in priorities

An admitted set is one directly assigned local literal containing 1–64 unique, homogeneous direct int, finite float, or bool literals. PyCForge proves that set order cannot be observed, then lowers storage to a read-only fixed automatic C array.

Empty sets, set comprehensions, duplicate elements, strings, heterogeneous or computed elements, inline membership sets, indexing, iteration, methods, mutation, aliasing, rebinding, passing, return, and escape reject. Set iteration is deliberately excluded because Python set order is not a portable observable order; it reports PYC3412. Set indexing reports PYC3411.

Dictionaries

def lookup() -> int:
    values = {'low': 1, 'high': 2}
    return values['high']

Container rejection boundary

Rejected forms include empty or oversized containers, heterogeneous or nested containers, comprehensions, generator expressions, unpacking, duplicate dictionary keys, dynamic indexing, element mutation, container methods, rebinding, aliasing, passing, returning, or escape. The set-specific boundaries above are additional and intentional.

Immutable automatic static records

A deliberately narrow top-level class shape becomes an inline automatic C record. Each record has 1–64 ordered int, float, or bool fields, followed by exactly one structural __init__.

class Point:
    x: int
    y: int

    def __init__(self, x: int, y: int) -> None:
        self.x = x
        self.y = y

def sum_point(left: int, right: int) -> int:
    point = Point(left, right)
    return point.x + point.y

Record rejection boundary

Other methods, inheritance, decorators, class-level values, dynamic or string fields, mutation after construction, rebinding, copying, aliasing, method calls, passing or returning records, storing records in containers, importing records, and cross-module record use reject.

Why these boundaries exist. The fixed shape lets analysis prove storage, initialization, lookup, and lifetime without introducing a Python object runtime, garbage collector, or speculative heap ownership.