General protocols
These protocols cover iteration, comparison, operators, and hashing.
Iteration
Iterable[A]: values that can produce an iterator with__iter__and can therefore be used inforloops and other iteration-based APIs
Identity and comparison
Identity: identity comparison withisandis notEq: equality comparison with==and!=Ord (Eq): ordering with<,<=,>, and>=
If you see a constraint such as A(Ord) in a type
signature, it means values of type A support ordering.
Operator families
Logical:&,|,^, and their in-place formsPlus:+,+=, and__zero__Minus:-and-=Times[A] (Plus):*and*=, with right-hand operand typeADiv[A]:/and/=, with result typeA
Hashing
Hashable (Eq): values that can feed data into ahasher; required for dictionary keys and set elements
If you see a constraint such as A(Hashable), values of
type A can be used where hashing is required.
See Hashable for the full protocol reference and an implementation example.