Releases: evhub/coconut
v2.1.0 [The Spanish Inquisition]
Though a small release relative to v2.0.0, v2.1.0 includes a couple of pretty exciting changes, most notably custom operators and substantial performance improvements. See Coconut's documentation for more information on all of the features listed below.
Major changes:
- #4, #674: Coconut now supports custom operators! See the documentation for more information on how to declare, define, and use custom operators.
- #147: Very substantial performance improvements (up to 100x) when compiling small quantities of code (e.g. at the interpreter, in Jupyter notebooks, when using
xonsh, etc.). Compile times for large files should be unchanged. - #673: New
multi_enumeratebuilt-in for enumerating multi-dimensional arrays (e.g.numpyarrays).
Minor changes:
- #385: Universalized imports no longer trigger
mypyerrors. xonshsupport updated to the latestxonshversion, should now be enabled by default without requiringxonsh install coconut, and should now be substantially faster.- #672: New
in <expr>pattern for easier containment checking in pattern-matching. - #556: Coconut now respects
NOQA/noqacomments when showing warnings for unused imports in--strictmode.
v2.0.0 [How Not to Be Seen]
Coconut v2 is here! This is Coconut's first ever major version release since Coconut was first published, and it comes with some breaking changes, detailed below. Care has been taken to keep v2 as backwards-compatible as possible, but Python 3.10 adding pattern-matching of its own that conflicted with some of Coconut's old pattern-matching rules meant that breaking changes were going to be inevitable to ensure full compatibility.
Additionally, v2 introduces some pretty major new features such as multidimensional array literal/concatenation syntax! Check it all out below and see Coconut's documentation for more information on all of the features listed.
Breaking changes:
- #605: Coconut pattern-matching is now fully unified with Python 3.10 pattern-matching: pattern-matching always works the same way regardless of where it is used, always uses Python 3.10 rules, but also always supports all additional Coconut pattern-matching features. Some implications of this:
- Coconut now fully supports class patterns everywhere, including in pattern-matching function definition and destructuring assignment.
- As a result,
x is inttype-checking syntax is now deprecated in favor of using theint(x)class pattern. For cases where there is no rewriting as a class pattern,x `isinstance` intsyntax is also supported. - Pattern-matching for dictionaries has been changed so that
{"a": a}now matches a dictionary with at least"a"as a key rather than exactly"a"as its only key to be consistent with Python 3.10. Coconut will warn if such syntax is detected and suggest the explicit{"a": a, **_}or{"a": a, **{}}syntax instead.
- #639: Coconut
datatypes no longer support adding or multiplying them like tuples unless explicitly added via__add__/__mul__methods. - #623:
fmapover a Mapping (e.g.dict) now does a normal map instead of astarmap. Thus, you'll need to dofmap$(def ((k, v)) -> (new_k, new_v))instead offmap$((k, v) -> (new_k, new_v)). Old behavior can also be recovered withfmap$(starmap_over_mappings=True). - #615:
($[])spelling for the iterator slicing operator function has been removed in favor of.$[]and the normal getitem operator has been added as.[]. - #613: Precedence of the function composition operator
..has been lowered such thatf x .. g yis now equivalent to(f x) .. (g y)rather than((f x) .. g) y. - #635:
initializerkeyword argument inscanchanged toinitialto match the function signature ofreduce.
New language features:
- #628, #670: New multidimensional array literal and concatenation syntax! Concatenate two arrays with
[a ; a], write out 2D array literals as[1, 2;; 3, 4], with the number of semicolons denoting the axis from the end on which to concatenate. - #258, #669: New syntax for partially applying operator functions:
(.+1),(a+.),(.<|x), including support for custom operators as(. `plus` x). - #663: Better syntax for typing tuples: instead of
x: typing.Tuple[int, str], just:x: (int; str). - #633: New pattern-matching for loops, allowing for arbitrary destructuring pattern-matching in for loops.
- #622, #650: New anonymous named tuples for giving names to fields in temporary tuples. Just:
(a=1, b=2). - #626: New syntax for using partial application to convert a keyword argument into a positional argument. Just:
func$(kwd_arg=?). - #612: Combinators! Use
liftto "lift" a function up so that its arguments become unary functions. Also: ident, flip, const, of. - #616, #620: New
all_equalandcollectbybuilt-ins for working with iterables. - #124:
fmapnow supports asynchronous iterators. - #365 (thanks @ArneBachmann!): Equality checking with
=<expr>has been deprecated in favor of==<expr>; the former syntax will now raise an error in--strictmode. - #648: Class patterns now support a strict
.attr=<match>syntax that raises an error if theattrisn't present rather than failing the match. - #641: Iterable destructuring patterns now support a substantially wider array of allowable destructuring constructs (e.g.
[1] + x + [2] + y + [3]). - #603: New
as x(to explicitly bind a variable) andis x(to do an identity check) pattern-matching constructs. - #434 (thanks @ArneBachmann!): Conditional assignment using pattern-matching; infix patterns have been improved to support
a `pred` or b = <expr>syntax that binds toaifpredandbotherwise. - #670:
jaxsupport infmapand multidimensional array literal/concatenation. - #617, #647: New comma operator function
(,)for joining arguments into a tuple and new(raise)operator function for raising an exception. - #625: Matrix multiplication operator
@now supported on all Python versions. - #649 (thanks @hlizard!): Zero-argument
super()now supported on all Python versions. - #664: Coconut will now automatically backport
typingimports intotyping_extensionsimports when necessary. - #490 (thanks @pavelbraginskiy!):
:=assignment expressions can now be chained without parentheses. - #640: f-strings now supported in pattern-matching string patterns.
New compiler features:
- #632: Substantially improved syntax error messages with much finer-grained identification of the error location.
- #636: Coconut can now be used as a
xontribin thexonshshell to enable Coconut syntax. - #658: Coconut now supports
papermill. - #575: Better interpreter auto-completing.
- #629 (thanks @tbsexton!): New
coconut[kernel]installation option for installing only lightweight Jupyter kernel dependencies compared to the full support offered bycoconut[jupyter]. - #646: Better
coconut.convenienceAPI.
Bugfixes:
- #638 (thanks @ivanmkc!):
coconut --watchfor watching files for changes to be recompiled fixed. - #657 (thanks @tbsexton!): Jupyter kernel compatibility with new Jupyter/IPython versions fixed.
- #616: Iterator slicing no longer exhausts the entire iterator except when strictly necessary.
- #631: Fixed pattern-matching on
numpyarrays by registering them as Sequences. - #656 (thanks @hlizard!): Compilation on Windows should no longer convert names of compiled files to lowercase.
- #627 (thanks @fakuivan!): Support for starred function arguments before positional function arguments.
- #653 (thanks @fakuivan!): Fixed dotted names in class/data patterns.
- #655 (thanks @hlizard!): Certain complex f-strings no longer trigger internal Coconut exceptions.
- #667 (thanks @tom-a-horrocks!): Rare interpreter crashes fixed.
v1.6.0 [Vocational Guidance Counsellor]
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! 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.
Coconut 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.9, Python3.10, and/or Python3.11. - #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
@overridebuilt-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
flattenbuilt-in for flattening one layer of an iterable of iterables. - #574: Coconut now supports
reveal_typeandreveal_localsbuilt-ins that will print the inferred type of the contained expression when compiled withcoconut --mypy. - #421: Coconut now supports
yield deffunction definition syntax for explicitly specifying that you want a generator function, regardless of whether ayieldactually occurs somewhere in the function. - #598: Coconut now supports
if condition then x else yternary syntax in addition to Python'sx if condition else yternary syntax. - #544: Coconut now supports the additional
.[0][1]and.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
dict,tuple, andliststar and double-star unpackings across all Python versions. - #571 (thanks @tbsexton for the issue!): Coconut now fully supports Python 3.10
int | booltype annotation syntax, including compiling it to any Python version. - #572: Coconut's
zipandzip_longestbuilt-ins now supports a Python-3.10-stylestrictkeyword 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
execas a function on all Python versions. - #352 (thanks @ArneBachmann for the issue!): Coconut will now compile
enumimports intoaenumimports on targets that don't supportenum. - #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 Coconutv2). - #576: Coconut's
casesyntax now allows acaseskeyword to be used at the top level instead of thecasekeyword for clarity. - #603: Coconut now supports optional
as xexplicit 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 destflag for compiling additional files/directories with the samecoconutcommand, including splitting the compilation across multiple processes when--jobsis passed. - #497 (thanks @matanagasauce for the issue!): Coconut now supports a
# coding: coconutheader in.pyfiles to use Coconut syntax along with acoconut --site-installcommand to make all such automatic compilation behavior available without first importingcoconut.convenience. - #596, #597 (thanks @lazyprop for the PR!): Coconut now supports a
--vi-modeflag andCOCONUT_VI_MODEenvironment variable for enablingvimode 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 installingcoconut[asyncio].
Bugfixes:
- #577: As long as a
dataclasseslibrary exists at runtime, all Coconut targets now supportx: intsyntax for specifying the fields of adataclass. - #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_mapis now substantially more efficient in processing very large iterators. - #602:
orand|in pattern-matching will no longer sometimes run duplicate checks. - #593:
--no-wrapnow disablesfrom __future__ import annotationson 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
withstatements. - #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.
Coconut v1.6.0 should also compile about 10% faster on average than Coconut v1.5.0.
v1.5.0 [Fish License]
See Coconut's documentation for more information on everything listed below.
Features
- #545: Added support for embedding a Coconut interpreter for debugging; just
from coconut import embed; embed(). - #562: All lazy lists are now reiterable.
- #550: All enhanced built-ins are now reiterable when given an iterable.
- #542: New
None-aware pipe operators. - #105: New
zip_longestbuilt-in. - #552: Full PEP 553 (breakpoint built-in) support on all Python versions.
- #531: Add support for
=specifier inf-strings. - #508: Added
.multiple_sequential_calls()context managers toparallel_mapandconcurrent_map. - #540: Add
nb_conda_kernelsupport (thanks @tbsexton for reporting the issue). - #514, #523: Added
--no-wrapflag (thanks @QuestofIranon for the PR!). - #547: Added Coconut homebrew installation (thanks @SeekingMeaning for making this happen!)
Bugfixes:
- #548: Significantly improve pattern-matching performance.
- #561: Fix Python 3.9 issues (thanks @BruceEckel for reporting the issue).
- #551: Fix issues with new Jupyter kernel (thanks @regr4 for reporting the issue and @bj0 for finding the root cause).
- #281: Fix
coconut --jupytercalling the wrong Jupyter installation (thanks @betabrain for reporting the issue). - #560: Fix error on non-numeric
setuptoolsversions (thanks @fabianhjr for the PR!). - #559: Fix nested
f-string parsing (thanks @bjo for reporting the issue). - #553: Proper PEP 563 support (now Coconut doesn't wrap annotations in strings when they'll be deferred anyway).
- #536: Fixes iterator
returns on all Python versions. - #541: Prevent accidentally compiling to source files (thanks @dryprogrammer for reporting the issue).
v1.4.3 [Ernest Scribbler]
See Coconut's documentation for more information on everything listed below.
Bugfixes:
- #527: Coconut once again builds properly on Python 2 (thanks @hasufell for the issue!)
- #526: fixes
=function definition returning string literals not working (thanks @vietspaceanh for the issue!) - attributes now work properly in implicit function application (e.g.
f b.x c.y)
v1.4.2 [Ernest Scribbler]
See Coconut's documentation for more information on all of the features listed below.
Bugfixes:
- #521: prevents Coconut from installing an incompatible version of
cPyparsingby default - #515: prevents Coconut from installing
trolliuson Python 3 when doingpip install coconut[all](thanks @DennisMitchell for the issue!)
New features:
- #496, #506:
addpatternnow issues a warning if passed a non-pattern-matching function unlessallow_any_func=Trueis passed (thanks @m-burst for the PR and @pavelbraginskiy for the issue!) - #517: simple implicit function application such as
f x yis now supported
v1.4.1 [Ernest Scribbler]
See Coconut's documentation for more information on all of the features listed below.
New features:
- #465: new
addpattern defshorthand syntax (thanks @MichalMarsalek for the issue!) - #301, #504, #505: full support for Python 3.6 f-strings on all targets including (thanks @m-burst for the PR!)
- #323: added support for
|**>kwargs pipes (thanks @ArneBachmann for the issue!) - #490: new
(assert)operator function (thanks @arnauorriols for the issue!) - #503: added support for Python 3.8 positional-only arguments (thanks @pavelbraginskiy fo the issue!)
- #483:
fmapnow works on numpy arrays (thanks @hoishing for the issue!) - #494: added support for pattern-matching in
datadefinitions (thanks @arnauorriols for the issue!) - #493: added truncation for long MatchError messages (thanks @arnauorriols for the issue!)
- #482: added support for Python 3.8 assignment expressions under
--target 3.8(thanks @terrdavis for the issue!) - #446, #458:
datatypes are now hashable (thanks @m-burst for the PR!) - #502:
addpattern,recursive_iterator, and TCO'd functions are now pickleable - #488: fewer
__coconut__.pyfiles are created when compiling in--packagemode
Plus lots and lots of bugfixes!
v1.4.0 [Ernest Scribbler]
See Coconut's documentation for more information on all of the features listed below.
New features:
- #320: added import hook to automatically compile imported Coconut files (thanks @ArneBachmann!)
- #347: added
whereclauses - #270: added a
memoizedecorator (thanks @iamrecursion!) - #403: added a
TYPE_CHECKINGconstant - #409: added support for
M `bind` x -> ysyntax - #419:
datatype equality is now typed (thanks everyone in #418!) - #331: support negative pattern-matching with
match ... not in ... - #411:
countnow supports a step size of0 - #394:
scannow has an initializer argument - #398: creating a new indented block after a colon is no longer necessary for any statement
- #229:
--strictnow warns on unused imports - #327: interpreter now supports
reloadbuilt-in (thanks, @ArneBachmann!) - #382: interpreter now supports compiling to arbitrary file names
- #393: unicode operators for multiplication and matrix multiplication have been switched
- #153: function composition precedence is now such that
f..g(x)is the same asf..(g(x))not(f..g)(x) - #395: built-in attributes changed to remove initial underscores
Plus lots and lots of bugfixes!
v1.3.1 [Dead Parrot]
This is a bugfix release for v1.3.0. See v1.3.0 below for all the most recently added features.
Fixes:
- #326: fixed Jupyter kernel installation (thanks, @auscompgeek!)
- #333: fixed
--watchplacing compiled files in the wrong location (thanks, @dileep-kishore!) - #337: fixed
--jupyter consoleon Windows (thanks, @mlarocca!) - #317: fixed numerous MyPy errors (thanks, @ArneBachmann!)
v1.3.0 [Dead Parrot]
See Coconut's documentation for more information on all of the features listed below.
New features:
- #220: new function composition pipe operators (thanks, @cgarciae!)
- #243: new none-aware operators
- #200: new enhanced type annotation syntax (thanks, @fredcallaway!)
- #257:
datatypes now support default arguments - #276:
datatypes now support type annotations (thanks, @jonathanplatzer!) - #275: pipes and infix calls now support lambdas in them
- #256: new string destructuring pattern-matching
- #267: improved dictionary pattern-matching (thanks, @cgarciae!)
- #284: new
starmapbuilt-in - #271: new
reiterablebuilt-in (thanks, @pchampin!) - #266: new
scanbuilt-in - #297, #309: new
groupsofbuilt-in (thanks, @kbaskett248!) - #303:
datamakerdeprecated in favor of newmakedatabuilt-in - #283:
prepatterndeprecated - #282:
fmapof a mapping now iterates over its.items() - #286: new
--argvcommand-line option - #300: Coconut now installable via
conda - #53: now supports
cPyparsingfor faster parsing
Fixes:
- #280: fixed infix notation associativity
- #268: tail call optimization now significantly faster
- #147: removed interpreter lag on first line of code
- #279: prettier interpreter errors
- #298: pattern-matching function docstrings now actually get bound to
__doc__ - #285:
type: ignorecomments now work properly - #255: fixed nested attribute getter implicit partial (thanks, @Socialery!)
- #269: fixed segfault in non-iterator functions (thanks, @pchampin!)
- #264: fixed
recursive_iteratorerror (thanks, @pchampin!) - #308: fixed importing
StringIOandBytesIOon Python 2 (thanks, @cgarciae!) - #295: fixed Cygwin error (thanks, @halloleo!)
- #288: fixed Pythonista installation error (thanks, @iamrecursion!)
- #277: fixed Jupyter kernel installation error (thanks, @petrilli!)
- #311: now gracefully handles old
pyparsingversions - #294: piping into partials no longer creates intermediate partial objects