I'm searching for a (probably obvious) way of reducing the time my code takes to run.
At the moment my code looks like this:
import numpy as np
from matplotlib import pyplot as plt
l = 4000000
def my_func(n):
m = 3 * n
z = n**2
return(m,z)
am = []
az = []
for i in range(l): # question is referring to this loop
am.append(my_func(i)[0])
az.append(my_func(i)[1])
x = range(l)
plt.plot(x, am)
plt.plot(x, az)
plt.show()
In the i-loop my_func always runs twice and discards one of the two returned values, which sounds super inefficient to me. So how can I fill my am array with the first and my az array with the second values my_func returns, without running it twice for every i and only using half the returns every time?

