Standard Protocol Rules

Every object o has the protocol type(o). Every instance of class X, has protocol X. An object has protocol p, if p is a class protocol of its class, or any direct or indirect base of that class.

An object o of type t has protcol p if add_type_proto(t,p) has_been called. An object o which is an instance of class c, has protocol p if add_class_protol(b,p) has been called, where b is c or one of its direct or indirect bases.

An object o has protocol p if add_obj_proto(o,p) has been called and returned normally.

It is not possible to attach protocols to an object using add_obj_proto unless the object either has a readable attribute '__protocols__' which is a mutable sequence, or will set an attribute '__protocols__' (which can subsequently be read).

Please note the crucial distinction between the protocols of a class object c, which include c.__protocols__, and the protocols of instances of c, which include c.__class_protocols__. A class object is an object in its own right and obeys protocols distinct from its instances.

Similarly, note that a type object has different protocols than the instances of that type.