def _find_impl(cls, registry):
 mro = _compose_mro(cls, registry.keys())
 match = None
 for t in mro:
  if (match is not None):
   if ((t in registry) and (t not in cls.__mro__) and (match not in cls.__mro__) and (not issubclass(match, t))):
    raise RuntimeError(u'Ambiguous dispatch: {0} or {1}'.format(match, t))
   break
  if (t in registry):
   match = t
 return registry.get(match)

def _find_impl ( cls , registry ) : mro = _compose_mro ( cls , registry . keys ( ) ) match = None for t in mro : if ( match is not None ) : if ( ( t in registry ) and ( t not in cls . __mro__ ) and ( match not in cls . __mro__ ) and ( not issubclass ( match , t ) ) ) : raise RuntimeError ( u'Ambiguous dispatch: {0} or {1}' . format ( match , t ) ) break if ( t in registry ) : match = t return registry . get ( match )
returns the best matching implementation from *registry* for type *cls* .