Built-in protocols
Built-in protocols are defined in __builtin__.
They show up in generic constraints, operator behavior, and the APIs of built-in collections. This section is reference material for the protocols that come with the language.
Built-in protocol constraints are part of the type system, not just documentation. They affect which operators are available, which generic functions typecheck, and how protocol methods are resolved.
The built-in protocols are grouped here as:
- General protocols for iteration, comparison, operators, and hashing
- Numeric protocols for number-like types
- Collection protocols for collection-shaped APIs
Read a header such as protocol Ord (Eq) as "Ord
extends Eq". A type that implements Ord must also satisfy
the requirements of Eq.
For how protocols work as a language feature, read Protocols.