def get_typename(cls):
    """Finds the typename string of the given ``cls``.

    :param cls: the class object to find its typename
    :type cls: :class:`type`
    :returns: the typename
    :rtype: :class:`basestring`

    """
    mod = cls.__module__
    if mod in ('__main__', '__builtin__'):
        return cls.__name__
    return mod + '.' + cls.__name__