def ftime(secs):
    """Formats a string to show time in a human readable form.

    Args:
        secs (int or float): The number of seconds.

    Returns:
        str: A formatted time string or empty string if value is 0.

    Examples:
        >>> ftime(23011)
        '6h 23m'

    Note:
        This function has been refactored for perfomance.

    """
    secs = int(secs)
    if secs <= 0:
        time_str = ''
    elif secs < 60:
        time_str = '{}s'.format(secs)
    elif secs < 3600:
        time_str = '{}m {}s'.format(secs // 60, secs % 60)
    elif secs < 86400:
        time_str = '{}h {}m'.format(secs // 3600, secs // 60 % 60)
    elif secs < 604800:
        time_str = '{}d {}h'.format(secs // 86400, secs // 3600 % 24)
    elif secs < 31449600:
        time_str = '{}w {}d'.format(secs // 604800, secs // 86400 % 7)
    else:
        time_str = '{}y {}w'.format(secs // 31449600, secs // 604800 % 52)
    return time_str
