-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exception handling O(n) -> O(1) x 2.
This commit is the last in a commit chain fundamentally refactoring the private `beartype._decor._code._pep._error` subpackage responsible for raising human-readable exceptions in the event of type-checking violations from a linear- to constant-time algorithm, while still preserving optional support for linear-time behaviour in anticipation of permitting end users to conditionally enable linear-time type-checking under some subsequent stable release of `beartype`. Specifically, this commit refactors our exception handler to conditionally switch between O(1) and O(n) behaviour as required by the parent `@beartype`-decorated wrapper function. ## Features Optimized * **`O(n)` → `O(1)` exception handling.** `@beartype` now internally raises human-readable exceptions in the event of type-checking violations with an `O(1)` rather than `O(n)` algorithm, significantly reducing time complexity for the edge case of invalid large sequences either passed to or returned from `@beartype`-decorated callables. For forward compatibility with a future version of `beartype` enabling users to explicitly switch between constant- and linear-time checking, the prior `O(n)` exception-handling algorithm has been preserved in a presently disabled form. (*Standard deviation of an enviable discombobulation!*)
- Loading branch information
Showing
6 changed files
with
228 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.