# Comparing the computational time of two ways of the same result

The two following codes accomplish the same task

1)

```
L=list(range(0,100,10))
Ld0=[x^2 for x in L]
Lc=[]
a=0
for i in range(len(Ld0)):
if (Ld0[i]%6 == 0) & (Ld0[i]<= 3200) :
Lc.append(Ld0[i])
a+=1
```

2)

```
L=list(range(0,100,10))
Ld0=[x^2 for x in L]
Ld2=[x for x in Ld0 if (x%6 == 0) & (x<= 3200)]
```

which can be shown by `Lc==ld2`

.

If I can fin easily the cpu computation time in adding `%time`

to the first, this is not the case for the second. How to see which way is the fastest ?

On peut virer le

`list`

dans la première ligne. et utiliser un itérateur dans la deuxième.If there is no obvious winner, you can run the two algorithms in parallel, and stop computation as soon as one produces the result - see https://ask.sagemath.org/question/59480/