Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

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.