コード例 #1
0
def extract_tuple_eltypes(tuple_type, n):
    """
    Extract the element types from the (static) tuple type and return them
    in a tuple.
    """
    if typematch(tuple_type, StaticTuple):
        return extract_statictuple_eltypes(tuple_type)
    else:
        assert typematch(tuple_type, GenericTuple), tuple_type
        base_type = tuple_type.parameters[0]
        return (base_type, ) * n
コード例 #2
0
ファイル: tupleobject.py プロジェクト: flypy/flypy
def extract_tuple_eltypes(tuple_type, n):
    """
    Extract the element types from the (static) tuple type and return them
    in a tuple.
    """
    if typematch(tuple_type, StaticTuple):
        return extract_statictuple_eltypes(tuple_type)
    else:
        assert typematch(tuple_type, GenericTuple), tuple_type
        base_type = tuple_type.parameters[0]
        return (base_type,) * n
コード例 #3
0
def extract_statictuple_eltypes(tuple_type):
    if typematch(tuple_type, EmptyTuple):
        return ()

    hd, tl = tuple_type.parameters
    return (hd, ) + extract_statictuple_eltypes(tl)
コード例 #4
0
ファイル: tupleobject.py プロジェクト: flypy/flypy
def extract_statictuple_eltypes(tuple_type):
    if typematch(tuple_type, EmptyTuple):
        return ()

    hd, tl = tuple_type.parameters
    return (hd,) + extract_statictuple_eltypes(tl)