@lower_builtin('getitem', types.UniTuple, types.intp)
@lower_builtin('getitem', types.NamedUniTuple, types.intp)
def getitem_unituple(context, builder, sig, args):
    tupty, _ = sig.args
    tup, idx = args

    bbelse = builder.append_basic_block("switch.else")
    bbend = builder.append_basic_block("switch.end")
    switch = builder.switch(idx, bbelse)

    with builder.goto_block(bbelse):
        context.call_conv.return_user_exc(builder, IndexError,
                                          ("tuple index out of range",))

    lrtty = context.get_value_type(tupty.dtype)
    with builder.goto_block(bbend):
        phinode = builder.phi(lrtty)

    for i in range(tupty.count):
        ki = context.get_constant(types.intp, i)
        bbi = builder.append_basic_block("switch.%d" % i)
        switch.add_case(ki, bbi)
        with builder.goto_block(bbi):
            value = builder.extract_value(tup, i)
            builder.branch(bbend)
            phinode.add_incoming(value, bbi)

    builder.position_at_end(bbend)
    res = phinode
    assert sig.return_type == tupty.dtype
    return impl_ret_borrowed(context, builder, sig.return_type, res)
dataset/ETHPy150Open numba/numba/numba/targets/tupleobj.py/getitem_unituple/original