Skip to content

0.4.0

Choose a tag to compare

@franknoh franknoh released this 25 Sep 07:38
· 280 commits to main since this release
3480d56

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

  • str lowers to native code under ppy run, in standalone binaries, and in emitted C and C++. What lowers:
    • literals, +, *, and comparisons;
    • indexing and slicing with steps;
    • in, iteration, ord/chr, and int()/float() parsing;
    • str()/repr()/format();
    • f-strings with full format specs;
    • split, join, strip, replace, find, startswith, the is... tests, the case methods, and more.
  • 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(), and isinstance. A Base-typed value holds any subclass.
  • Operator methods (__add__, __eq__, __lt__, __getitem__, __contains__, ...).
  • In-place writes like points[i].x = 3, and field(default_factory=...).
  • Type-argument inference: Pair(1, 2.5), s: Stack[int] = Stack(), v: Vec[int] = Vec().

Collections

  • Map and set API:
    • keys(), values(), and items();
    • setdefault, update, and pop(key, default);
    • set algebra (|, &, -, ^, issubset, ...).
  • Sequence API:
    • slicing, insert, remove, index, count;
    • sort(key=..., reverse=...);
    • construction from iterables.
  • enumerate, zip, sorted, min, max, and sum over 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-strict reports downgraded findings as W2010 warnings instead of dropping them.
  • The documentation site has a new design.
  • New examples: 48_strings and 49_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.