# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):


from muninn._compat import itervalues, imap, izip
    from collections.abc import MutableSet
    from collections import MutableSet
        else:
            return prototype in prototypes

    def __iter__(self):
        for prototypes in itervalues(self._prototypes):
            for prototype in prototypes:
                yield prototype

    def __len__(self):
        return sum(imap(len, itervalues(self._prototypes)))

    def add(self, prototype):
        try:
            self._prototypes[prototype.name].add(prototype)
        except KeyError:
            self._prototypes[prototype.name] = set((prototype,))

    def discard(self, prototype):
        try:
            self._prototypes[prototype.name].discard(prototype)
        except KeyError:
            pass

    def resolve(self, prototype):
        top, top_equal = [], 0
        for candidate in self._prototypes[prototype.name]:
            if candidate.arity != prototype.arity:
                continue

            equal, compatible = 0, 0

# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):


# Path: muninn/function.py
from muninn._compat import itervalues, imap, izip
    from collections.abc import MutableSet
    from collections import MutableSet

        else:
            return prototype in prototypes

    def __iter__(self):
        for prototypes in itervalues(self._prototypes):
            for prototype in prototypes:
                yield prototype

    def __len__(self):
        return sum(imap(len, itervalues(self._prototypes)))

    def add(self, prototype):
        try:
            self._prototypes[prototype.name].add(prototype)
        except KeyError:
            self._prototypes[prototype.name] = set((prototype,))

    def discard(self, prototype):
        try:
            self._prototypes[prototype.name].discard(prototype)
        except KeyError:
            pass

    def resolve(self, prototype):
        top, top_equal = [], 0
        for candidate in self._prototypes[prototype.name]:
            if candidate.arity != prototype.arity:
                continue

            equal, compatible = 0, 0

            for candidate_type, type_ in izip(candidate.argument_types, prototype.argument_types):