You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove base _CachingProtocolMeta and use beartype's instead
Now that beartype/beartype#86 has landed (and made it into a release), we can remove our own base implementation and use that one instead. We still provide our own implementation that allows overriding runtime checking, but it neatly derives from ``beartype``'s.
If you use ``beartype``for type-checking your code, but don’t want ``numerary``to use it internally, set the ``NUMERARY_BEARTYPE`` environment variable to a falsy[^6] value before ``numerary`` is loaded.
558
+
``numerary``will not use ``beartype`` internally unless the ``NUMERARY_BEARTYPE`` environment variable is set to a truthy[^6] value before ``numerary`` is loaded.
562
559
563
560
[^6]:
564
561
565
-
I.E., one of: ``0``, ``off``, ``f``, ``false``, and ``no``.
562
+
I.E., one of: ``1``, ``on``, ``t``, ``true``, and ``yes``.
566
563
567
564
See the [hacking quick-start](https://posita.github.io/numerary/0.3/contrib/#hacking-quick-start) for additional development and testing dependencies.
* Now relies on ``#!python beartype.typing.Protocol`` as the underlying caching protocol implementation.
21
+
This means that ``beartype`` is now ``numerary``’s only runtime dependency.
22
+
(``numerary`` still layers on its own runtime override mechanism via [CachingProtocolMeta][numerary._protocol.CachingProtocolMeta], which derives from ``beartype``’s.)
23
+
24
+
This decision was not made lightly.
25
+
``numerary`` is intended as a temporary work-around.
26
+
It’s obsolescence will be something to celebrate.
27
+
Caching protocols, however, have much broader performance applications.
28
+
They deserve more.
29
+
``beartype`` will provide what ``numerary`` was never meant to: a loving, stable, and permanent home.
Copy file name to clipboardExpand all lines: docs/numerary.types.md
+4-8Lines changed: 4 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@
23
23
I am working toward stability as quickly as possible, but be warned that future release may introduce incompatibilities or remove this package altogether.
24
24
[Feedback, suggestions, and contributions](contrib.md) are desperately appreciated.
25
25
26
-
In addition to the following protocols and helper functions, ``numerary.types`` also resolves importing ``Annotated``, ``Protocol``, and ``runtime_checkable`` from the best available source.
26
+
Because ``numerary`` uses ``beartype`` in its implementation, you can use both to resolve importing ``Annotated``, ``Protocol``, and ``runtime_checkable`` from the best available source.
27
27
This can be helpful if you need to support Python versions prior to 3.9, but don’t want to make a conditional import of ``typing_extensions`` everywhere.
28
28
Instead of doing this all over the place …
29
29
@@ -37,18 +37,13 @@ except ImportError:
37
37
… you can do this instead …
38
38
39
39
```python
40
-
from numerary.types import Annotated, Protocol, runtime_checkable
40
+
from beartype.typing import Annotated, runtime_checkable
41
+
from numerary.types import Protocol
41
42
```
42
43
43
44
Bang.
44
45
Done.
45
46
46
-
Further, if you want to opportunistically take advantage of [``beartype``](https://github.com/beartype/beartype/) without imposing a strict runtime dependency, you can do this:
47
-
48
-
```python
49
-
from numerary.bt import beartype # will resolve to the identity decorator if beartype is unavailable at runtime
50
-
```
51
-
52
47
Which you should totally do, because ``beartype`` is *awesome*.
53
48
Its author is even *awesomer*.[^1]
54
49
@@ -90,6 +85,7 @@ Its author is even *awesomer*.[^1]
0 commit comments