Coconut

Latest version: v3.1.2

Safety actively analyzes 687918 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 8

3.0.1

See Coconut's [documentation](http://coconut.readthedocs.io/en/develop/DOCS.html) for more information on all of the features listed below.

This is a patch release primarily aimed at fixing 746, though it also brings a couple of new features and other fixes as well.

New features:
* 743: New `f(...=long_name)` syntax as a shorthand for `f(long_name=long_name)`.
* 744: `f ..> g` will now preserve the signature of `f` when inspected using `inspect.signature`.

Language changes:
* 736: `fmap` will now raise `TypeError` rather than falling back to a default implementation when it encounters an unknown type. For backwards compatibility, the old behavior can be recovered with `fmap$(fallback_to_init=True)`.
* 737: `fmap` now works properly on `multiset`.

Bugfixes:
* 746: Syntax errors produced when using Coconut's Jupyter kernel will now present themselves nicely rather than causing an error.
* 745 (thanks Starwort!): `xonsh` will no longer fail on semicolon-seperated commands when using the Coconut extension.
* 739 (thanks yggdr!): Compiling a single directory in `--stand-alone` mode will now properly make use of `--jobs`.
* 742 (thanks kloczek!): Fixed a deprecation warning when installing Coconut.

3.0.0

Coconut v3! See Coconut's [documentation](http://coconut.readthedocs.io/en/develop/DOCS.html) for more information on all of the features listed below.

Note that v3 is a major version release that comes with some breaking changes, though Coconut will do its best to warn you if your code does anything that changed from v2 to v3.

Breaking changes:
* 714: `set` patterns now work like `dict` patterns where they allow extra keys, such that `{1, 2}` will match `{1, 2, 3}`. To get back the strict behavior, use the `{1, 2, 3, *()}` pattern. Coconut will warn you if your code contains set patterns without an explicit strictness marker.
* 707: the precedence of implicit function application has been changed to be compatible with implicit coefficients, such that `f x**2` is now equivalent to `f(x**2)` rather than `f(x)**2`. Coconut will warn you if your code contains expressions with new precedence.
* 733: `.$[]` will now only default to using an existing `__getitem__` if the object is registered as a `collections.abc.Sequence`. `__iter_getitem__` will still always be used. Lets you do things like `{"k": "v"}$[0]`.
* 730: `obj.` syntax as a shorthand for `getattr$(obj)` deprecated.
* 732: `--jobs` now defaults to `sys` rather than `0`.

New features:
* 707: New implicit coefficient syntax! Polynomials are just `a x**2 + b x + c`, with support for single variable names and numeric constants as coefficients.
* 731: New `copyclosure def` functions that copy their closures on function creation, allowing them to e.g. hold on to loop variables.
* 709: `(+)` syntax in a typing context now yields a `typing.Protocol` that requires supporting that operator.
* 709: New `&:` operator for combining multiple `typing.Protocol`'s into a single protocol.
* 718 (thanks yggdr!): You can now use `addpattern def` even if there's no existing function of that name, allowing you to use `addpattern def` for every pattern rather than having to use `match def` for the first one.
* 727: New `x |> await` syntax for using `await` in pipes.
* 734: Substantially improved `pandas` support.
* 714: New `frozenset` and `multiset` patterns.

Bugfixes:
* 725 (thanks yggdr!): Fixed `(in)` operator function argument ordering.
* 721 (thanks yggdr!): `is not` and `not in` operator functions now supported.
* 724 (thanks Starwort!): Coconut no longer slows down `xonsh` loading and fixed `xontrib unload coconut`.
* 726 (thanks caedmon-kitty!): Fixed certain `xonsh` commands when using Coconut's `xonsh` plugin.
* 723: `dict` now always functions as on the latest Python 3 on any Python version.
* 728 (thanks yggdr!): Fixed `super` compatibility across Python versions and some cases where `super()` wouldn't work.
* 717 (thanks kksgandhi!): Fixed `coconut --jupyter qtconsole`.

2.2.0

See Coconut's [documentation](http://coconut.readthedocs.io/en/develop/DOCS.html) for more information on all of the features listed below.

Major changes:
- 694: New `multiset` built-in based on `collections.Counter`, including new multiset literal syntax (`m{1, 1, 2, 3, 3, 4}`).
- 691: New `Expected` built-in based on Haskell's `Either`, plus new `safe_call` built-in that calls a function while collecting any errors into an `Expected`. Additionally, the `of` built-in has been renamed to `call` (`of` is still available as a deprecated alias when compiled without `--strict`).
- 701: New `windowsof` built-in for iterating over sliding windows of the given iterable.
- 688: New `cartesian_product` built-in as an enhanced version of `itertools.product` including `numpy` support.
- 690: New `cycle` built-in as an enhanced version of `itertools.cycle`.
- 704, 703, 702, 693, 692: Lots of improvements to existing built-ins:
* `map` now supports a `strict=True` keyword-only argument that works as in `zip`.
* `flatten` now supports a `levels` argument for how many levels to flatten.
* `groupsof` now supports a `fillvalue` argument to pad the last group.
* `addpattern` now accepts any number of pattern-matching functions.
* `memoize` now accepts a function to memoize as the first argument.
- 710: New `None`-aware function composition pipes (e.g. `f ..?> g`).

Minor changes:
- 686: Type parameter bounds can (and should) now use `<:` syntax instead of `:` or `<=` (e.g. `def f[T <: int[])(xs: T) -> T = ...`).
- 711: Backwards `None`-aware pipes now supported (e.g. `<?|`).
- 708: Pattern-matching against `data` types with default arguments now allows those defaults to be elided in the `match`.
- 697: `::` now produces a reiterable object when called on reiterable objects.
- 706: Multiple Coconut projects should now be able to seamlessly use each other's `MatchError`s when compiled in `--package` mode.
- 695: Set literal syntax now supports star unpacking.
- 699: Support for `__bool__` magic method fixed on Python 2.
- 687: Jupyter kernel and other automatic compilations now uses `--no-wrap`.
- 685, 684: Improved detection of code issues on and off `--strict`.
- 700: Some confusing unicode alternatives were removed.
- 698: Typing for `fmap` has been improved.
- 689: Improved `numpy` support for some built-ins.
- 705: Many Coconut built-ins have now been made `weakref`able.

2.1.1

v2.1.1 is a relatively small release on top of v2.1.0 primarily releasing now to provide Python 3.11 support, though v2.1.1 also has a couple of exciting new features, primarily Coconut's new type parameter syntax. See Coconut's [documentation](http://coconut.readthedocs.io/en/develop/DOCS.html) for more information on all of the features listed below.

Bugfixes:
- 682: Coconut no longer errors out on Python 3.11.

Major changes:
- 677: New type parameter syntax following [PEP 695](https://peps.python.org/pep-0695/)! For example: type a generic function as `def ident[T](x: T) -> T = x`.

Minor changes:
- 679: Error and logging output is now colored on terminals that support it.
- 678: Non-`mypy` type checkers should now have an easier time type-checking Coconut code.
- 680: New `async (...) -> ...` and `(..., **P) -> ...` enhanced type annotation constructs for Callables following [PEP 677](https://peps.python.org/pep-0677/).
- 644: `f = async def x -> x` async statement lambda syntax now supported.
- 624: `x |> (.+1)` syntax now produces better optimized compiled Python.
- 681: `case`/`match` syntax now deprecated on `--strict` in favor of Python 3.10 `match`/`case` syntax.

2.1.0

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](http://coconut.readthedocs.io/en/latest/DOCS.html) 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_enumerate` built-in for enumerating multi-dimensional arrays (e.g. `numpy` arrays).

Minor changes:
* 385: Universalized imports no longer trigger `mypy` errors.
* `xonsh` support updated to the latest `xonsh` version, should now be enabled by default without requiring `xonsh 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`/`noqa` comments when showing warnings for unused imports in `--strict` mode.

2.0.0

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](http://coconut.readthedocs.io/en/develop/DOCS.html) 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](https://peps.python.org/pep-0622/#class-patterns) everywhere, including in pattern-matching function definition and destructuring assignment.
- As a result, `x is int` type-checking syntax is now deprecated in favor of using the `int(x)` class pattern. For cases where there is no rewriting as a class pattern, ``x `isinstance` int`` syntax 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 `data` types no longer support adding or multiplying them like tuples unless explicitly added via `__add__`/`__mul__` methods.
* 623: `fmap` over a Mapping (e.g. `dict`) now does a normal map instead of a `starmap`. Thus, you'll need to do `fmap$(def ((k, v)) -> (new_k, new_v))` instead of `fmap$((k, v) -> (new_k, new_v))`. Old behavior can also be recovered with `fmap$(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 that `f x .. g y` is now equivalent to `(f x) .. (g y)` rather than `((f x) .. g) y`.
* 635: `initializer` keyword argument in `scan` changed to `initial` to match the function signature of `reduce`.

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 `lift` to "lift" a function up so that its arguments become unary functions. Also: ident, flip, const, of.
* 616, 620: New `all_equal` and `collectby` built-ins for working with iterables.
* 124: `fmap` now 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 `--strict` mode.
* 648: Class patterns now support a strict `.attr=<match>` syntax that raises an error if the `attr` isn'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) and `is 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 to `a` if `pred` and `b` otherwise.
* 670: [`jax`](https://jax.readthedocs.io/en/latest/index.html) support in `fmap` and 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 `typing` imports into `typing_extensions` imports 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 `xontrib` in the [`xonsh`](https://xon.sh/) shell to enable Coconut syntax.
* 658: Coconut now supports [`papermill`](https://papermill.readthedocs.io/en/latest/).
* 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 by `coconut[jupyter]`.
* 646: Better `coconut.convenience` API.

Bugfixes:
* 638 (thanks ivanmkc!): `coconut --watch` for 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 `numpy` arrays 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.

Page 2 of 8

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.