Optimize a given code in Python for higher efficiency.
def power(base, exponent):
    answer = 1
    for _ in range(exponent):
        answer *= base
    return answer
def power(base, exponent):
    answer = 1
    while exponent > 0:
        if exponent & 1:
            answer *= base
        base *= base
        exponent >>= 1
    return answer