Skip to content

Commit

Permalink
Don't hide CachingProtocolMeta (#17)
Browse files Browse the repository at this point in the history
Fixes #15.
  • Loading branch information
posita committed Oct 12, 2022
1 parent 7428f95 commit a286677
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 19 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ More attributes means more comparisons.
Further, it performs these comparisons … Every. Single. 🤬ing. Time.

Protocols provided by ``numerary`` use instead [``CachingProtocolMeta``](https://posita.github.io/numerary/0.4/numerary.types/#numerary.types.CachingProtocolMeta) as their meta class.
``CachingProtocolMeta`` derives from ``type(Protocol)`` and overrides ``__instancecheck__ `` to cache results based on instance type.
``CachingProtocolMeta`` derives from ``type(beartype.typing.Protocol)`` which caches results based on instance type.
``numerary``’s version allows for runtime check overrides of those results.

Conceptually:

Expand Down
8 changes: 4 additions & 4 deletions docs/notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

* Now relies on ``#!python beartype.typing.Protocol`` as the underlying caching protocol implementation.
This means that ``beartype`` has emerged as ``numerary``’s sole runtime dependency.
(``numerary`` still layers on its own runtime override mechanism via [CachingProtocolMeta][numerary._protocol.CachingProtocolMeta], which derives from ``beartype``’s.)
(``numerary`` still layers on its own runtime override mechanism via [CachingProtocolMeta][numerary.protocol.CachingProtocolMeta], which derives from ``beartype``’s.)
It also means that ``numerary`` loses Python 3.7 support, but that was largely illusory anyway.

This decision was not made lightly.
Expand Down Expand Up @@ -77,9 +77,9 @@

## [0.1.0](https://github.com/posita/numerary/releases/tag/v0.1.0)

* Adds [``CachingProtocolMeta.includes``][numerary._protocol.CachingProtocolMeta.includes],
[``CachingProtocolMeta.excludes``][numerary._protocol.CachingProtocolMeta.excludes], and
[``CachingProtocolMeta.reset_for``][numerary._protocol.CachingProtocolMeta.reset_for]
* Adds [``CachingProtocolMeta.includes``][numerary.protocol.CachingProtocolMeta.includes],
[``CachingProtocolMeta.excludes``][numerary.protocol.CachingProtocolMeta.excludes], and
[``CachingProtocolMeta.reset_for``][numerary.protocol.CachingProtocolMeta.reset_for]
cache override functions.
* Retires ``…SCT`` tuples as unnecessary, especially in light of cache overrides.
(Runtime ``isinstance`` protocol checking is fast enough.)
Expand Down
41 changes: 41 additions & 0 deletions docs/numerary.protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!---
Copyright and other protections apply. Please see the accompanying LICENSE file for
rights and restrictions governing use of this software. All rights not expressly
waived or licensed are reserved. If that file is missing or appears to be modified
from its original, then please contact the author before viewing or using this
software in any capacity.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!! IMPORTANT: READ THIS BEFORE EDITING! !!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Please keep each sentence on its own unwrapped line.
It looks like crap in a text editor, but it has no effect on rendering, and it allows much more useful diffs.
Thank you!
-->

# ``#!python numerary.protocol`` package reference

!!! warning "Experimental"

This package is an attempt to ease compatibility between Python’s numbers and types.
If that sounds like it shouldn’t be a thing, you won’t get any argument out of me.
Anyhoo, this package should be considered experimental.
I am working toward stability as quickly as possible, but be warned that future release may introduce incompatibilities or remove this package altogether.
[Feedback, suggestions, and contributions](contrib.md) are desperately appreciated.

``numerary`` has donated its core caching protocol implementation to (and now depends on) [``beartype``](https://github.com/beartype/beartype).
``beartype`` is *awesome*, and its author is even *awesomer*.[^1]
``numerary``’s version (in this package) augments that implementation to allow for runtime check overrides.

[^1]:

I acknowledge that the subject of who is awesomer, beartype or the man who made it, is [hotly contested](https://github.com/beartype/beartype/issues/66#issuecomment-960495976).

::: numerary.protocol
rendering:
show_if_no_docstring: false
show_root_heading: false
show_root_toc_entry: false
selection:
members:
- "CachingProtocolMeta"
13 changes: 0 additions & 13 deletions docs/numerary.types.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@
I am working toward stability as quickly as possible, but be warned that future release may introduce incompatibilities or remove this package altogether.
[Feedback, suggestions, and contributions](contrib.md) are desperately appreciated.

``numerary`` has donated its core caching protocol implementation to (and now depends on) ``beartype``.
``beartype`` is *awesome*, and its author is even *awesomer*.[^1]

[^1]:

I acknowledge that the subject of who is awesomer, beartype or the man who made it, is [hotly contested](https://github.com/beartype/beartype/issues/66#issuecomment-960495976).


::: numerary._protocol.CachingProtocolMeta
rendering:
show_if_no_docstring: false
show_root_heading: true

::: numerary.types
rendering:
show_if_no_docstring: false
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ nav:
- License: license.md
- API:
- <tt>numerary</tt>: numerary.md
- <tt>numerary.protocol</tt>: numerary.protocol.md
- <tt>numerary.types</tt>: numerary.types.md

# See:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion numerary/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from beartype.typing import SupportsInt as _SupportsInt
from beartype.typing import SupportsRound as _SupportsRound

from ._protocol import CachingProtocolMeta
from .bt import beartype
from .protocol import CachingProtocolMeta

if TYPE_CHECKING:
from typing import Protocol
Expand Down

0 comments on commit a286677

Please sign in to comment.