Is there a way to push the following `for`

loop down to the `numpy`

level in the case of generating a sequence based on previous values?

```
n = int(10**5)
x = np.empty(n+1)
x[0] = 0.1
for t in range(n):
x[t+1] = 4 * x[t] * (1 - x[t])
```

I have been looking at np.nditer and @guvectorize decorator as one possible solution. This example above is taken from the `need_for_speed`

python lecture.

There are a lot of cases where it would be nice to `pre-allocate`

an empty array in memory and then role through the same array populating values based on a function and some initial values for generating sequences.

As demonstrated by the lecture, `jit`

is a very useful tool in this case to speed up and optimize the `loop`

. Is it the case then that I should always use `jit`

for recursive formulations? Is this a good general rule of thumb?

I am thinking about this question as @natashawatkins sent me an interesting SciPy video that demonstrated the use of `@vectorize`

from the `numba`

package and got some good performance values using generated custom `ufuncs`

here. I guess even if you could generate generalized `ufuncs`

that loop over arrays, they probably won’t be faster than `jit`

solution anyway.