def version_compare(version1, version2):
    """Compare two version iterables consisting of arbitrary number of numeric elements."""
    len_version1 = len(version1)
    len_version2 = len(version2)
    if len_version1 == len_version2:
        # Both version objects have the same number of components, compare them left to right
        for i in range(len_version1):
            if version1[i] > version2[i]: return 1
            elif version1[i] < version2[i]: return -1
        # version objects compare equal
        return 0
    elif len_version1 > len_version2:
        version2_tmp = list(version2)
        while len(version2_tmp) < len_version1: version2_tmp.append(0)
        return version_compare(version1, version2_tmp)
    else:
        version1_tmp = list(version1)
        while len(version1_tmp) < len_version2: version1_tmp.append(0)
        return version_compare(version1_tmp, version2)