Question: I have a Python script that reads 1000 lines from a CSV file.

Why is iterating the `csv.reader` object in a list comprehension 4 orders of magnitude slower than the equivalent explicit for loop?

Here are the code snippets and their times (via `time.time()`) on my machine:

```py
with open("file.csv", 'r', newline = "\n") as f:
    reader = csv.reader(f, delimiter = ",")
    data = [r for i, r in enumerate(reader) if i < 1000]

# Time: 26.459498167037964 s

```

```py
with open("file.csv", 'r', newline = "\n") as f:
    reader = csv.reader(f, delimiter = ",")
    data = []
    for i, r in enumerate(reader):
        if i >= 1000:
            break
        data.append(r)

# Time: 0.005597114562988281 s

```

EDIT:

As per the answers, the list comprehension version reads the whole file and only selects the elements that satisfy the condition `i < 1000`, while the explicit loop stops as it reaches `i == 1000`.

For future readers of this question, the most elegant solution was written by @decenze in the comments:

```py
import csv
from itertools import islice

with open("file.csv", 'r', newline = "\n") as f:
    reader = csv.reader(f, delimiter = ",")
    data = list(islice(reader, 0, 1000))

```

Answer: 
I ran into the same problem and it looks like there is a problem with static html site. Today version 2.0.79 was released and it supports an --html flag. At least my app is now working.
The tutorial guide you use the Azure Cloud Shell to deploy it, but as you know the CLI in the Cloud Shell is version 2.0.78 and it does not support the parameter `--html` and you also cannot upgrade the CLI in the Cloud Shell. 

The parameter now is only supported in version 2.0.79. So the solution is to install the CLI in your own environment. Follow the steps [here](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) to install the CLI then it will work well with the parameter `--html`.