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
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,12 +61,12 @@ method[type, ...] # get registered function
61
61
method[type, ...] = func # register function by explicit types
62
62
```
63
63
64
-
Multimethods support any types that satisfy the `issubclass` relation, including abstract base classes in `collections.abc`. Note `typing` aliases do not support `issubclass` consistently, and are no longer needed for subscripts. Using ABCs instead is recommended. Subscripted generics are supported:
64
+
Multimethods support any types that satisfy the `issubclass` relation, including abstract base classes in `collections.abc`. Note `typing` aliases do not support `issubclass` consistently, and are no longer needed for subscripts. Using ABCs instead is recommended. Subscripted generics are supported by custom `isinstance` checks:
65
65
*`Mapping[...]` - the first key-value pair is checked
66
66
*`tuple[...]` - all args are checked
67
67
*`Iterable[...]` - the first arg is checked
68
-
*`type[...]`
69
-
*`Literal[...]`
68
+
*`type[...]` - `issubclass` of type
69
+
*`Literal[...]` - equality and type match
70
70
*`Callable[[...], ...]` - parameter types are contravariant, return type is covariant
71
71
72
72
Naturally checking subscripts is slower, but the implementation is optimized, cached, and bypassed if no subscripts are in use in the parameter. Empty iterables match any subscript, but don't special-case how the types are normally resolved.
0 commit comments