Repository navigation
0.3.7
Changes
- Standalone builds read
float, the fixed widths (ppy.i8throughppy.u64,ppy.f32,ppy.f64), tuples of them, and buffers and lists of numbers natively. A standaloneprintwrites a float the wayreprdoes. ppy.input[Model]()reads a line of JSON into a dataclass, a pydantic model, or aTypedDict;ppy.scan[Model]()reads a JSON value across lines. Mismatches name the path ($.items[2].price).- Collections that compile:
Vec,Deque,Heap,MaxHeap,LinkedList,HashMap,HashSet,TreeMap,TreeSet. They hold numbers, tuples, dataclasses, and other collections (Vec[Vec[int]],HashMap[tuple[int, int], int]), are reference counted, and lower underppy run, in standalone binaries, and in emitted C and C++. - Generic functions take, make, and return collections of their type parameter, with one native instance per type.
- Object classes lower to native code: trees and linked nodes (
left: "Node | None"), methods,is None,len(obj),if obj:. Reference cycles are not freed. - Generic classes (
class Stack[T]) are checked per type argument and instantiated per type argument natively. - The documentation site is redesigned and every page rewritten.
from ppy import Deque, Vec
def farthest(adjacent: Vec[Vec[int]]) -> int:
seen = Vec[int](len(adjacent))
queue = Deque[int]()
queue.push_back(0)
seen[0] = 1
best: int = 0
while queue:
node: int = queue.pop_front()
for other in adjacent[node]:
if seen[other] == 0:
seen[other] = seen[node] + 1
best = max(best, seen[other])
queue.push_back(other)
return best - 1Install or upgrade with pip install --upgrade ppy-lang==0.3.7.
The full repository gate passed: 1,811 tests, 42/42 examples on all three paths, and the documentation examples. The emitted C of the collection and object tests runs clean under AddressSanitizer with leak detection.