In this case primes does not even need to be a list, it can just be a generator.
def goldbach(number):
if number % 2 == 0: #Only even numbers
primes = primenums(number) #returns all prime numbers <= input number
addend1 = primes[0]
addend2 = primes[0]
while addend1 + addend2 != number:
if primes[-1] == addend2:
addend2 = primes[primes.index(addend1) + 1]
addend1 = primes[primes.index(addend1) + 1]
else:
addend2 = primes[primes.index(addend2) + 1]
return addend1, addend2
raise ValueError("Goldbach conjecture is only defined for even numbers")
And primenums is a simple sieve:
def prime_sieve(limit):
prime = [True] * limit
prime[0] = prime[1] = False
for i, is_prime in enumerate(prime):
if is_prime:
yield i
for n in range(i * i, limit, i):
prime[n] = False
def primenums(limit):
return list(prime_sieve(limit))

And when pulling the generation of the primes outside of the function (and calculating them up to the largest number in the plot):

Of course the first three functions are vastly slower than the set because they need to go through more combinations now. However, all functions are then constant time, so the increase in time comes solely from the fact that you have to consider more primes.