Skip to content

Releases

unpythonic 2.5.0 — "Turtles all the way down"

Choose a tag to compare

@Technologicat Technologicat released this 16 Sep 09:01

New:

  • Update one item deep inside nested containers, like Clojure's update-in and assoc-in. The path is a sequence of steps — keys, indices, and attribute names, in any mix — so dicts, lists, envs, named tuples, frozen dataclasses and frozendicts can all be walked through in one call.
    • mogrify_in_with(func, path, container) and mogrify_in_to(value, path, container) update in-place, with mogrify's semantics: every mutable container along the path keeps its identity, and an immutable one is rebuilt and stored back into its parent.
    • fupdate_in_with(target, path, func) and fupdate_in_to(target, path, value) are the functional variants, which never mutate their input and share everything off the path with it.

Fixed:

  • A shallow copy of an env — copy.copy, or fupdate given an env — now has bindings of its own. It used to share them with the original, so rebinding a name in the copy rebound it in the original too.
  • namedlambda's docstring now says it names a lambda bound in an env-assignment or let binding in either spelling, := or <<. It listed only <<, right after a bullet where := meant Python's own named expression, so a reader could conclude the walrus form is not named.
  • The REPL documentation now says that the client reads piped stdin, running each line in the session namespace — so a shell script can drive a live app with nobody at the keyboard. The docs described only the interactive session, which is the smaller half of what the client does.
    • It also names the trap that makes an automated check necessary: the session echoes the value of an expression and a statement has none, so a pipe made only of assignments prints nothing and looks identical whether it ran or not. Have such a script print something and check for it; python3 -m unpythonic.net.server is a throwaway host to test the pipe against first.

unpythonic 2.4.0 — "'Tis but a scratch"

Choose a tag to compare

@Technologicat Technologicat released this 17 Aug 14:03

Python 3.15 support. The language grew two pieces of syntax that change the AST, and the macro layer needed no overhaul to take them — lazify, autocurry, tco and continuations all pass the new comprehension forms through untouched. The work here is the tests that establish that, rather than any change to what the macros do.

New:

  • Python 3.15 is supported. requires-python moves from <3.15 to <3.16, and mcpyrate 4.3.0 or newer is now required, since earlier versions cannot import anything at all under 3.15.
    • The macros needed no changes for the new syntax. lazify, autocurry, tco and continuations all pass comprehension unpacking ({**mapping for x in xs}, [*items for item in xs], and the set and generator forms) through untouched.
    • There are now tests to keep it that way, and they check the properties rather than the results — laziness by leaving a 1 / 0 unevaluated, currying by partially applying, TCO by recursing deeper than the stack allows. A lazify that had quietly gone strict inside the new forms would return the right answer and fail these.

Changed:

  • env.finalize() now returns self instead of None, so it can be chained: e = env(x=42).finalize(). Matches the existing instance passthrough on <<.

See the changelog for the documentation fixes also included in this release.

unpythonic 2.3.0 — "Mind the gap"

Choose a tag to compare

@Technologicat Technologicat released this 14 Aug 08:39

New:

  • unpythonic.misc.si_prefix: new parameters separator and always_separate, for callers that append a unit of measurement.
    • separator (default " ", per SI) is what goes between the number and the prefix; separator="" gives the compact "1.50k" that some UIs prefer.
    • always_separate emits the separator even where the magnitude needs no prefix, so f"{si_prefix(n, always_separate=True)}W" reads "1.50 kW" and "42.00 W" rather than "1.50 kW" and "42.00W". Without it the spacing depends on the magnitude, which is exactly what a caller appending a unit does not want.

unpythonic 2.2.0 — "Hail Eris"

Choose a tag to compare

@Technologicat Technologicat released this 12 May 13:47

Two new dialects, esoteric and qualitatively different.

The dialects

  • unpythonic.dialects.bf — Brainfuck as a dialect. Source-to-source transpiler with legible Python output (bf.compile(src) returns the generated code as a string for inspection). 8-bit wrapping tape via defaultdict[int, int]; bf source comments preserved as Python comments; reset line clears the tape between programs.
  • unpythonic.dialects.befunge — Befunge-93 as a dialect. Runtime interpreter for a strict 80×25 toroidal playfield with byte cells and an unbounded-int stack. All Befunge-93 commands supported, including ? (random direction; seedable via run(src, *, seed=...) for tests), p/g (self-modifying code), and &/~ (integer/character input). The bf/befunge pair demonstrates mcpyrate's Dialect.transform_source hook in two qualitatively different modes: dialect-as-transpiler (bf) and dialect-as-reader (befunge — Befunge's 2D self-modifying control flow has no statically-soundable structure).

Other new

  • expect[] — new expr macro for declaring the tested expression inside with test:. Replaces return expr, which still works but emits a DeprecationWarning and will be un-hijacked in 3.0.0 so return regains its standard Python meaning inside with test:.
  • unpythonic.excutil.withf — with as a function. Expression form completing the raisef/tryf/withf suite. Single CM or tuple; body arity auto-detected.
  • @multishot, myield, myield_from, MultishotIterator — multi-shot generators. A @multishot function is generator-shaped but every myield captures the execution state as a continuation, so it can be resumed from any earlier myield arbitrarily many times. MultishotIterator exposes a subset of the standard generator protocol plus copy.copy(mi) forking. Only meaningful inside with continuations:. Closes #80.
  • Values unpacking in unpythonic.funutil.call and callwith. Each Values in positional args expands in place (left-to-right), splicing rets into positional args and merging kwrets into kwargs. Mirrors Python's [*a, *b, c] / {**a, **b} semantics.
  • FrozenAttributeError — compatibility shim multiply inheriting from TypeError (legacy) and dataclasses.FrozenInstanceError (stdlib convention). Raised by cons on attribute write/delete. The TypeError base will be dropped in 3.0.0.
  • redirect_stdin — context manager feeding sys.stdin from a stream. The third sibling of contextlib.redirect_stdout/stderr, which the stdlib never shipped.

Fixed

  • unpythonic.misc.callsite_filename now uses sys._getframe instead of inspect.stack(). Latent PyPy-3.11 / macOS / Windows bug: inspect.stack() raised TypeError when any frame in the walk reported f_lineno = None.
  • unpythonic.llist.cons.__delattr__ now raises FrozenAttributeError. Latent bug: del c.car previously corrupted the cell.
  • unpythonic.assignonce now forbids del e.foo on a defined name. Latent bug: the assign-once contract could be bypassed via del; rebind.

Changed

  • lispython, listhell, pytkell dialects propagate the Python 3.8+ source-location fields end_lineno / end_col_offset through splice_dialect alongside lineno / col_offset. Tooling that consumes precise source ranges (debuggers, PEP 657 traceback formatters) gets richer information. Closes #83.
  • Requires mcpyrate >= 4.2.0.

Docs

  • doc/macros.md: new "Topology of continuations" and "Scoping of locals in continuations" subsections. Closes #82.

Milestone 2.2.0 complete. Closes #35, #76, #80, #82, #83, #85 (step 1; step 2 milestoned to 3.0.0), #86.

v2.1.0 — "Cat-hedral" edition

Choose a tag to compare

@Technologicat Technologicat released this 17 Apr 17:41

2.1.0 (17 April 2026) — "Cat-hedral" edition:

New:

  • unpythonic.monads: subpackage of classical monads — Identity, Maybe, Either (with Left/Right), List, Writer, State, Reader. Plus Monad/LiftableMonad base classes and liftm/liftm2/liftm3 helpers. Not re-exported at the top level; import as from unpythonic.monads import Maybe.
  • monadic_do: do-notation macro over any monad. with monadic_do[M] as result: with body [bindings] in result << final_expr; supports := (primary) and << (legacy) for bindings; empty bindings allowed; _ := mexpr for sequencing. Always used as the innermost with (body shape constraint), composes correctly with lazify/continuations/tco/autocurry/etc.
  • environ_override: context manager to temporarily override OS environment variables within a with block, restoring the previous state on exit.
    • Thread-safe (serialises concurrent overrides via RLock); same-thread nesting supported.
    • New module unpythonic.environ; the function is named override at the module level and re-exported as environ_override at the top level.
  • maybe_open: context manager that opens a file when given a path, or yields a fallback stream (e.g. sys.stdin, sys.stdout) when given None.
    • Lets callers always use with syntax regardless of whether the target is a file or a standard stream.
  • UnionFilter: a logging.Filter that matches a log record if any of its sub-filters match.
    • This is an OR combinator that is oddly missing from the standard library.
  • si_prefix: format a number with SI decimal prefixes (k through Q, m through q) or IEC binary prefixes (Ki through Qi, mi through qi).
    • Handles negative numbers, zero, and sub-unity magnitudes.
    • The binary=True flag switches to base-1024 mode.
  • partial (type-checking wrapper over functools.partial) is now exported in the public API.
    • It was already implemented but missing from fun.__all__.
  • Sliced, FupTarget, Fuppable: tag types in unpythonic.slicing for annotating the return values of islice and fup.
    • Sliced has abstract __getitem__.
    • FupTarget has abstract __getitem__ returning Fuppable.
    • Fuppable has abstract __lshift__.
  • slift1, slift2: lift scalar unary/binary operations to work termwise on iterables, returning imathified lazy generators. Accept optional extra arguments baked into each call (e.g. slift1(round, 2)). These are the mechanism behind all built-in s-prefixed operators, now exposed for user-defined functions.
  • ConditionProtocol: typing.Protocol capturing the call signature shared by error-handling protocols (signal, error, cerror, warn). Useful for annotating custom protocols.

Changed:

  • unpythonic.amb.MonadicList: the implementation was moved to unpythonic.monads.List and renamed. MonadicList remains as a silent alias of List for name compatibility, scheduled for removal in 3.0.0. The constructor uses varargs (List(1, 2, 3)) — the class itself is the monadic unit (List(x) is a singleton list). Iterable-constructor use-cases go through List.from_iterable(iterable).
  • unpythonic.net (REPL server and client) now runs on MS Windows.
    • Previously the whole subsystem was POSIX-only because unpythonic.net.ptyproxy required termios, tty, and os.openpty.
    • A new socket.socketpair()-based backend stands in for the pty master/slave endpoints on Windows, plugged in via a platform dispatch in PTYSocketProxy.
    • Known wart: os.isatty(sys.stdin.fileno()) inside a REPL session returns False on Windows (no real pseudo-terminal is involved), whereas it returns True on POSIX — user code inside the REPL that checks sys.stdin.isatty() will see the Windows result; the framework itself doesn't care.

Fixed:

  • unpythonic.net.server: start() now returns the actually-bound ports, not the values the caller passed in.
    • Matters when passing repl_port=0 / control_port=0 to let the kernel pick a free port — previously the caller got (bind, 0, 0) back.
    • Also fixes a latent bug in unpythonic.net.util.ReuseAddrThreadingTCPServer: its custom server_bind() override dropped the self.server_address = self.socket.getsockname() refresh from stdlib's TCPServer.server_bind.
  • unpythonic.net.ptyproxy: stop() is now idempotent and safe to call on a proxy that was never started.
    • Latent bug: previously stop() gated the entire teardown (including os.close(master) / os.close(slave)) behind if self._thread:, so constructing a proxy and then exiting without calling start() leaked both fds.
  • unpythonic.net.client: tab completion now works on macOS.
    • macOS ships readline backed by libedit, which speaks a different parse_and_bind dialect than GNU readline — the client now detects platform.system() == "Darwin" and issues the libedit form there.
  • unpythonic.misc.timer and unpythonic.timeutil.ETAEstimator: switched from time.monotonic() to time.perf_counter().
    • Latent Windows-only bug: monotonic is backed by a ~16 ms tick counter on Windows, so microsecond-scale with timer() as t: ... blocks recorded t.dt = 0.0 and downstream divisions raised ZeroDivisionError. perf_counter has the highest available resolution on every platform. POSIX unaffected.
  • unpythonic.arity._kwargs: generic dispatch path used dict instead of set for accumulating kwargs names. Latent bug — only triggers if a @generic function has keyword-only arguments.
  • unpythonic.test.runner: module discovery no longer crashes on MS Windows with re.error: bad escape.
    • The runner used re.sub(os.path.sep, ...) — os.path.sep is a lone backslash on Windows, an invalid regex pattern. Fixed by using str.replace. Affects any project reusing unpythonic.test.runner.

Internal:

  • unpythonic.net now has an automated test suite for the REPL client and server.
    • unpythonic/net/tests/test_client.py exercises the full client ↔ server roundtrip in-process (eval, multi-line, syntax-error recovery, clean disconnect), netcat-mode raw-socket access, control-channel RPC, and stretch cases (sequential reconnect, two concurrent clients). Tier 1 only — no subprocess / pty driver. Runs on every CI platform (Linux, macOS, Windows).
  • unpythonic.net.ptyproxy: refactored into an abstract base class with platform-specific backends (PosixPTYSocketProxy via os.openpty, WindowsPTYSocketProxy via socket.socketpair).
    • Dispatch happens inside PTYSocketProxy.__new__, so callers instantiate the base class and get the right backend for free.
    • PTYSocketProxy is now a context manager (with PTYSocketProxy(...) as proxy:) for guaranteed cleanup. Public interface otherwise unchanged.
  • unpythonic.net.client: connect() is now a thin public shim over a private _connect(..., _input=None).
    • The _input seam lets tests drive the REPL loop without monkey-patching builtins.input globally. Public API unchanged.
  • unpythonic.net.client: import readline moved from module top into connect(), with a three-tier fallback (readline → pyreadline3 → graceful degradation).
    • POSIX behaviour unchanged; the module is now importable on Windows.
  • unpythonic.net.tests.fixtures.nettest: binds on port 0 (kernel-assigned), removed a sleep(0.05) race-condition bandage, and re-raises worker-thread exceptions instead of swallowing them.
  • Type annotations added to public API signatures (and private helpers/closures) across 32 modules.
    • Full list of newly type-annotated modules: regutil, symbol, assignonce, numutil, misc, excutil, fup, fix, environ, fun, it, fold, funutil, lazyutil, ec, singleton, env, gtco, amb, tco, slicing, dynassign, gmemo, llist, fploop, let, lispylet, seq, collections, arity, conditions, mathseq.
    • Remaining unannotated: dispatch, typecheck (hard tier — deeply dynamic).
    • Convention: F = TypeVar('F', bound=Callable) for callable parameters, T = TypeVar('T') for data values.
  • amb cleanups.
    • Assignment renamed to Choice.
    • Internal env class renamed to Scope.
    • MonadicList constructor standardized to accept a single iterable (like list/tuple); Sequence methods added (__reversed__, __contains__, index, count); registered as Container/Iterable/Sized/Sequence ABC.
  • slicing: New Sliced and FupTarget/Fuppable tag types with abstract methods, used as return types for islice and fup. Public API for type annotations, exported in __all__.
  • collections: Internal class _StrReprEqMixin renamed to _SequenceReprEqMixin.
    • __eq__ now requires Sequence and raises TypeError for incompatible types (latent bug: previously crashed on non-Sized input).
    • roview._cache attribute now declared in __init__.
    • _make_negidx_converter.convert now has explicit return None for passthrough path.
  • arity._bind: rebased from Python 3.8.5 inspect.Signature._bind to Python 3.14. Adds deferred positional-only-in-kwargs handling, updated error messages. Divergence points marked with [unpythonic] for easy auditing. OrderedDict → dict throughout (ordered since 3.7).
  • mathseq: hasattr(x, "__iter__") → isinstance(x, Iterable) (3 sites). imathify registered as virtual subclass of Iterable. Internal primitive_* operator aliases renamed to atom_*. spow/sround varargs (*mod, *ndigits) changed to int | None = None.
  • Bare object() sentinels replaced with sym/gensym for debug readability.
    • Affected: ec.py (gensym("anchor")), llist.py (gensym("fill"), module-level), fold.py (sym("_uselast")), test_conditions.py, test_collections.py.

Version 2.0.0

Choose a tag to compare

@Technologicat Technologicat released this 16 Mar 10:25

2.0.0 (16 March 2026) — "Six impossible things before breakfast" edition:

IMPORTANT:

  • Python version support: 3.10–3.14 (dropped 3.8, 3.9; added 3.13, 3.14). PyPy 3.11.
    • If you need unpythonic for Python 3.8 or 3.9, use version 1.0.0.
  • Requires mcpyrate >= 4.0.0.
    • mcpyrate 4.0.0 dropped the Str, Num, NameConstant AST compatibility shims and the getconstant helper. Use ast.Constant directly, and .value to get the constant's value.

New:

  • Python 3.13 and 3.14 support.
  • autoreturn macro now handles match/case statements. Each case branch has its own tail position.
  • New scope analyzer tests for match/case patterns and try/except*.
  • New unpythonic.test.runner module: reusable test runner with module discovery, version-suffix gating (e.g. test_foo_3_11.py skipped on Python < 3.11), and integration with the test framework's warning system. Other projects using unpythonic.test.fixtures can import it directly.
  • New emit_warning() function in unpythonic.test.fixtures for signaling test warnings from infrastructure code (outside test[]/warn[] macros). Used by the test runner for version-suffix skips, which show in the warning count for the innermost enclosing testset.
  • Missing optional dependencies (sympy, mpmath) in tests emit warn[] instead of error[], correctly reflecting that these are expected skips, not failures.
  • Runtime type checker (unpythonic.typecheck): new supported typing features — NoReturn, Never (3.11+), Literal, Type, ClassVar, Final, DefaultDict, OrderedDict, Counter, ChainMap, IO/TextIO/BinaryIO (mapped to io module ABCs), Pattern[T]/Match[T] (string type checked when parametric), ContextManager, AsyncContextManager, Awaitable, Coroutine, AsyncIterable, AsyncIterator, Generator, AsyncGenerator.
  • Runtime type checker: TypedDict support — structural checking of required/optional keys and value types.
  • Runtime type checker: Protocol support — @runtime_checkable Protocols work via isinstance; non-runtime-checkable Protocols raise TypeError with an actionable message.
  • Runtime type checker: parametric forms of abstract ABCs — Iterable[T], Collection[T], Reversible[T] perform best-effort element checking (elements checked when value is Sized; ABC-only for opaque iterators). Iterator[T] and Container[T] accept parametric form with type arg silently ignored (iterating an Iterator would consume it; Container only has __contains__, so elements can't be enumerated).

Fixed:

  • Runtime type checker (unpythonic.typecheck): fixed compatibility with Python 3.14, where typing.Union is no longer a _GenericAlias. Now uses typing.get_origin (available since 3.8).
  • Runtime type checker: fixed TypeVar detection to use isinstance(T, typing.TypeVar) instead of a fragile repr-based heuristic.
  • Runtime type checker: typing.Reversible check now uses isinstance instead of a hasattr("__reversed__") workaround from the Python 3.5 era.
  • Runtime type checker: removed redundant safeissubclass fallbacks for generic types — typing.get_origin handles both bare and parameterized generics on 3.10+.
  • Scope analyzer: fixed MatchCapturesCollector bug where class references (e.g. Point in case Point(x, y):) were incorrectly collected as captured variable names.
  • Macro layer: updated all hasattr(tree, "ctx") checks to use getattr with defaults, for correct behavior on Python 3.13+ where AST fields always exist with default values.
    • Important: Since Python 3.13, the default of ctx is Load(), hence no AST node has its ctx in a "not set yet" state anymore. Hence, any macro-created Name nodes that appear in a Store or Del position MUST have their ctx set appropriately by the macro author. Failing to do so will cause mysterious errors during macro expansion.
  • Macro layer: updated arguments() constructor calls to always include posonlyargs=[], avoiding a DeprecationWarning on Python 3.13 (will become an error in 3.15).
  • MS Windows: unpythonic.net.util failed to load, due to missing termios module (which is *nix only) being loaded by unpythonic.net.__init__ when it imports unpythonic.net.ptyproxy.
    • Fixed by catching ModuleNotFoundError, disabling ptyproxy on MS Windows systems. Thus the remote REPL functionality unpythonic.net.client/server is not available on MS Windows, but the rest of unpythonic works fine.

Deprecated:

  • Parenthesis syntax for macro arguments (e.g. let((x, 1), (y, 2))). Use bracket syntax instead: let[[x, 1], [y, 2]]. The parenthesis syntax is kept for backward compatibility for now.
  • Runtime type checker: typing.Text (deprecated since Python 3.11) and typing.ByteString (deprecated since Python 3.12) support is now marked for removal when the floor bumps to Python 3.12.

v1.0.0 — "Same supercharger, new badge" edition

Choose a tag to compare

@Technologicat Technologicat released this 21 Feb 08:10

Re-release of 0.15.5 as 1.0.0. No code changes. The library has been stable and in light maintenance mode for years; the version number now reflects this de facto status quo.

Also includes CI modernization: Dependabot for GitHub Actions, bumped action versions to current.

Available on PyPI.

v0.15.5

Choose a tag to compare

@Technologicat Technologicat released this 16 Apr 12:48

0.15.5 (16 April 2025) - hotfix:

Changed:

  • Internal: Upgrade build system to pdm.

    • This is important for the road ahead, since the old setuptools build system has been deprecated.
    • The GitHub CI scripts for unpythonic now use PDM to manage the testing venv and dependencies, too. Now the tests should run the same way as they would on a local system.
  • Bump mcpyrate to the hotfix version 3.6.4.

    • The only difference is (beside mcpyrate too internally upgrading its build system to pdm) that the text colorizer now works correctly also for input with readline.

0.15.4 (27 September 2024) - hotfix:

Fixed

  • Bump mcpyrate to the hotfix version 3.6.3.
    • This is only to make sure no one accidentally installs the broken version, mcpyrate 3.6.2, which had a bug in interactive console mode that wasn't caught by CI.

v0.15.3

Choose a tag to compare

@Technologicat Technologicat released this 27 Sep 13:48

0.15.3 (27 September 2024) - New tree snakes edition:

IMPORTANT:

  • Minimum Python language version is now 3.8.
    • We support 3.8, 3.9, 3.10, 3.11, 3.12, and PyPy3 (language versions 3.8, 3.9, and 3.10).
    • Python 3.6 and 3.7 support dropped, as these language versions have officially reached end-of-life. If you need unpythonic for Python 3.6 or 3.7, use version 0.15.2.
  • Minimum version for optional macro expander mcpyrate is now 3.6.2, because the astcompat utility module was moved there.

New:

  • Python 3.12 support.
    • As in, all tests pass, so there are no regressions. Some undiscovered interactions with new language features (type statement) may still be broken, although the most obvious cases are already implemented.
  • Python 3.11 support.
    • As in, all tests pass, so there are no regressions. Some undiscovered interactions with new language features (try/except* construct) may still be broken, although the most obvious cases are already implemented.
  • Walrus syntax name := value is now supported, and preferred, for all env-assignments. Old syntax name << value still works, and will remain working at least until v0.16.0, whenever that is.
    • Note that language support for using an assignment expression inside a subscript without parenthesizing it was added in Python 3.10.
    • If you still use Python 3.8 or 3.9, with the new := syntax you must put parentheses around each let binding, because syntactically, the bindings subform looks like a subscript.
    • All documentation is written in Python 3.10 syntax; all unit tests are written in Python 3.8 syntax.

Changed:

  • Utility module unpythonic.syntax.astcompat, used by the macro layer, moved to mcpyrate.astcompat. This module handles version differences in the ast module in various versions of Python.

Fixed:

  • ETAEstimator edge case: at any point after all tasks have been marked completed, return a constant zero estimate for the remaining time.
  • Fix borkage in mathseq when running with SymPy 1.13 (SymPy is only used in tests). Bump SymPy version to 1.13.
  • Fix bug in scopeanalyzer: get_names_in_store_context now collects also names bound in match/case constructs (pattern matching, Python 3.10).

v0.15.2

Choose a tag to compare

@Technologicat Technologicat released this 19 Sep 11:59

0.15.2 (19 September 2024)

This time, just a small but important fix.

Fixed:

  • unpythonic.env.env is now pickleable. Save your fancy bunches into .pickle files and load them back!

Future plans:

Contrary to appearances, this project is not dead. But it already does most of what I personally need it to do, so it is pretty much in maintenance mode. And it has not required much maintenance over the past two years.

We still plan to officially support Python 3.11+ later, as well as to update all constructs with assignment semantics to use the more appropriate := operator, when/if I find the time to do so. The syntax uses << for historical reasons - these constructs were originally implemented in 2018, on Python 3.4, back when := did not exist.

The most likely upgrade timeframe is when I personally switch to Python 3.11+, and something breaks. That is also when I'll likely next upgrade the sister project mcpyrate.