pypi beartype 0.10.1
Beartype 0.10.1

latest releases: 0.21.0, 0.21.0rc0, 0.20.2...
3 years ago

Beartype 0.10.1 released.

This patch release cooks up scrumptious support for fast PEP 544 -- Protocols: Structural subtyping (static duck typing) and improved compliance with PEP 570 -- Python Positional-Only Parameters.

This patch release resolves 3 issues and merges 1 pull request. Noteworthy changes include:

Compatibility Improved

  • **PEP 570 -- Python Positional-Only Parameters, resolving issue #101 kindly submitted by typing luminary @dycw (Derek Wan). Previously, @beartype only supported positional-only parameters followed by one or more standard parameters in the signature of a callable. Now, @beartype unconditionally supports callables passed any permutation of positional-only and non-positional-only parameters– including callables passed only one or more positional-only parameters.

Compatibility Optimized

  • PEP 544 -- Protocols: Structural subtyping (static duck typing). The beartype.typing.Protocol superclass has now been significantly optimized to internally cache structural subtyping checks across isinstance() calls the same protocol and objects of the same type checked against that protocol. Doing so ensures that:
    • Only the first call to a @beartype-decorated callable annotated by one or more beartype.typing.protocol-style protocols will be as slow as equivalent calls to a @beartype-decorated callable annotated by one or more typing.Protocol-style protocols.
    • All subsequent calls will be memoized to leverage the results internally cached by the first such call, a ludicrous speedup over the stock typing.Protocol approach.

This optimization is entirely thanks to @posita the dynamite ("He's TNT!") devop, who miraculously migrated this caching behaviour from his own in-house numerary.types implementation. Thunderous applause for this third out of three tremendous contributions! Likewise, thanks so much for the grand critique that helped fuel this in my awkward and questionable absence, @TeamSpen210.

You both are the stuff open-source dreams are made of. (Heated cleats!)

Don't miss a new beartype release

NewReleases is sending notifications on new releases.