Include an example output from _compose_mro()

This commit is contained in:
Łukasz Langa 2013-05-25 16:12:02 +02:00
parent cab76cf1f0
commit 8190ba0c80
1 changed files with 13 additions and 0 deletions

View File

@ -190,6 +190,19 @@ argument which includes the relevant ABCs. The algorithm is as follows::
mro.insert(index, regcls) mro.insert(index, regcls)
return mro return mro
In its most basic form, it returns the MRO for the given type::
>>> _compose_mro(dict, [])
[<class 'dict'>, <class 'object'>]
When the haystack consists of ABCs that the specified type is a subclass
of, they are inserted in a predictable order::
>>> _compose_mro(dict, [Sized, MutableMapping, str, Sequence, Iterable])
[<class 'dict'>, <class 'collections.abc.MutableMapping'>,
<class 'collections.abc.Iterable'>, <class 'collections.abc.Sized'>,
<class 'object'>]
While this mode of operation is significantly slower, no caching is While this mode of operation is significantly slower, no caching is
involved because user code may ``register()`` a new class on an ABC at involved because user code may ``register()`` a new class on an ABC at
any time. In such case, it is possible to create a situation with any time. In such case, it is possible to create a situation with