Repository navigation
0.4.0
Changes
Ordinary Python data now compiles: text, class hierarchies, and the common container operations. They used to send a function back to CPython. Memory is reclaimed the way CPython reclaims it, cycles included, and a standalone binary that fails prints what CPython would have printed.
Strings
strlowers to native code underppy run, in standalone binaries, and in emitted C and C++. What lowers:- literals,
+,*, and comparisons; - indexing and slicing with steps;
in, iteration,ord/chr, andint()/float()parsing;str()/repr()/format();- f-strings with full format specs;
split,join,strip,replace,find,startswith, theis...tests, the case methods, and more.
- literals,
- Strings are collection elements and keys (
HashMap[str, int],TreeSet[str]) and class fields. They cross the Python boundary and are read and printed by standalone binaries.
Classes
- Single inheritance with dynamic dispatch,
super(), andisinstance. ABase-typed value holds any subclass. - Operator methods (
__add__,__eq__,__lt__,__getitem__,__contains__, ...). - In-place writes like
points[i].x = 3, andfield(default_factory=...). - Type-argument inference:
Pair(1, 2.5),s: Stack[int] = Stack(),v: Vec[int] = Vec().
Collections
- Map and set API:
keys(),values(), anditems();setdefault,update, andpop(key, default);- set algebra (
|,&,-,^,issubset, ...).
- Sequence API:
- slicing,
insert,remove,index,count; sort(key=..., reverse=...);- construction from iterables.
- slicing,
enumerate,zip,sorted,min,max, andsumover collections are native.- Functions that take or return collections are called natively from Python. Writes through arguments reach the caller.
Memory and errors
- Reference cycles (doubly linked lists, parent pointers) are collected.
- A call that falls back to Python frees what it allocated.
- Standalone binaries print CPython's final exception line (
KeyError: (3, -3),IndexError: pop from an empty Deque) and exit with status 1.
Also
--no-strictreports downgraded findings asW2010warnings instead of dropping them.- The documentation site has a new design.
- New examples:
48_stringsand49_inheritance.
Install or upgrade with pip install --upgrade ppy-lang==0.4.0. See CHANGELOG.md for the full list.
The full repository gate passed: 1,878 tests, 44/44 examples on all three paths, pylint on every example, and the documentation examples. The emitted C of the string, class, collection, and memory tests runs clean under AddressSanitizer with leak detection.