Barring any necessary hotfixes, this release,
v1.6.0, will be the last release on the
v1.X.X branch—which means next up is Coconut
v2 will include substantial backwards-incompatible changes to Coconut's pattern-matching syntax, as well as likely including other backwards-incompatible changes as well.
v1.6.0 includes a substantial list of new features, many of which have been added in anticipation of Coconut
v2. See Coconut's documentation for more information on all of the features and bugfixes listed below.
New language features:
- #558, #601: Coconut now fully supports Python 3.10 pattern-matching syntax, including compiling Python 3.10 pattern-matching syntax to any Python version and mixing and matching between Python 3.10 pattern-matching and Coconut pattern-matching (including in destructuring assignment and pattern-matching function definition).
- #566: Coconut can now specifically target Python
3.10, and/or Python
- #425 (thanks @ExpHP for the issue!): Coconut pattern-matching now supports view patterns that allow calling a function in pattern-matching and matching on the result.
- #607: Coconut pattern-matching now supports infix patterns that allow calling a binary boolean function in pattern-matching and matching only if the return value is truthy.
- #570: Coconut now supports an
@override built-in that, when used to decorate a method, asserts that it is overwriting some method from a base class.
- #582, #583 (thanks @aananko for the issue!): Coconut now supports a
flatten built-in for flattening one layer of an iterable of iterables.
- #574: Coconut now supports
reveal_locals built-ins that will print the inferred type of the contained expression when compiled with
- #421: Coconut now supports
yield def function definition syntax for explicitly specifying that you want a generator function, regardless of whether a
yield actually occurs somewhere in the function.
- #598: Coconut now supports
if condition then x else y ternary syntax in addition to Python's
x if condition else y ternary syntax.
- #544: Coconut now supports the additional
.a.b(c) implicit partials.
- #348 (thanks @ArneBachmann for the issue!): Pattern-matching functions now support return type annotations (though not argument type annotations).
- #289: Coconut now supports
list star and double-star unpackings across all Python versions.
- #571 (thanks @tbsexton for the issue!): Coconut now fully supports Python 3.10
int | bool type annotation syntax, including compiling it to any Python version.
- #572: Coconut's
zip_longest built-ins now supports a Python-3.10-style
strict keyword argument on all Python versions.
- #307: Coconut now supports
class A(metaclass=...) syntax on all Python versions, including compiling to universal code to support Python 2.
- #495 (thanks @pavelbraginskiy for the issue!): Coconut now supports
exec as a function on all Python versions.
- #352 (thanks @ArneBachmann for the issue!): Coconut will now compile
enum imports into
aenum imports on targets that don't support
- #365 (thanks @ArneBachmann for the issue!): Coconut now supports
== instead of
= as the prefix for equality checking in pattern-matching (this will be made mandatory in Coconut
- #576: Coconut's
case syntax now allows a
cases keyword to be used at the top level instead of the
case keyword for clarity.
- #603: Coconut now supports optional
as x explicit name-binding syntax in pattern-matching.
- #567: Coconut now supports in-line augmented global/nonlocal assignments.
New compiler features:
- #586, #591 (thanks @tbsexton for the issue!): Coconut now has an official VSCode highlighting extension.
- #587, #595 (thanks @nlipsyc for the PR!): Coconut now supports an
--and src dest flag for compiling additional files/directories with the same
coconut command, including splitting the compilation across multiple processes when
--jobs is passed.
- #497 (thanks @matanagasauce for the issue!): Coconut now supports a
# coding: coconut header in
.py files to use Coconut syntax along with a
coconut --site-install command to make all such automatic compilation behavior available without first importing
- #596, #597 (thanks @lazyprop for the PR!): Coconut now supports a
--vi-mode flag and
COCONUT_VI_MODE environment variable for enabling
vi mode in the interpreter.
- #386 (thanks @ArneBachmann for the issue!): Coconut will now throw more informative error messages for many common syntax errors.
- #611: Installing all the dependencies that Coconut uses to backport old code is now be done by installing
coconut[backports] rather than individually as in installing
- #577: As long as a
dataclasses library exists at runtime, all Coconut targets now support
x: int syntax for specifying the fields of a
- #578: Bound method are now properly tail call optimized.
- #604: When pattern-matching fails, it should no longer make any variable assignments (though in case of a guard, the variable assignments will still occur prior to the guard being run and will persist if the guard fails).
- #580 (thanks @leogao2 for the issue!): Coconut's
parallel_map is now substantially more efficient in processing very large iterators.
| in pattern-matching will no longer sometimes run duplicate checks.
--no-wrap now disables
from __future__ import annotations on Python 3.7+.
- #334: In-place pipe operators are now optimized the same as normal pipe operators.
- #543: Keyword-only function arguments will now raise a more informative error on unsupported targets.
- #588 (thanks @servadestroya for the issue!): Coconut will now properly compile vanilla Python destructuring assignment in
- #592 (thanks @servadestroya for the issue!): Coconut will now properly concatenate naked
f-strings placed next to each other.
- #519 (thanks @bj0 for the issue!): Coconut will no longer compile
:= operators inside of
:: expressions to invalid Python.
- #585 (thanks @Gurkenglas for the issue!): Coconut now has better handling of permission errors in Jupyter kernel installation.
v1.6.0 should also compile about 10% faster on average than Coconut