Question: I'm trying:

```
python3 -m timeit -c 'len("".join([str(x) for x in range(0, 999999)]))'
10 loops, best of 3: 330 msec per loop

python3 -m timeit -c 'sum((len(y) for y in [str(x) for x in range(0, 999999)]))
10 loops, best of 3: 439 msec per loop

```

Why does this happen? Is there a faster way?

P.S. It is assumed that a list of strings will be in advance.

Answer: 
A better benchmark with IPython shows the situation is worse than you thought:

```
>>> lst = [str(x) for x in range(0, 999999)]
>>> %timeit len("".join(lst))
100 loops, best of 3: 9.94 ms per loop
>>> %timeit sum(len(x) for x in lst)
10 loops, best of 3: 62.2 ms per loop

```

You're seeing two effects here, the overhead of function calls in Python and the overhead of its iteration. `"".join` doesn't have either because it's a single method call that does a loop in C. Intermediate performance with less memory use can be gotten from `map`:

```
>>> %timeit sum(map(len, lst))
10 loops, best of 3: 29.4 ms per loop

```
The first (faster) version has 1 call to the `len` function, 1 call to `join` and 100k calls to `str`. Looking at the second line you can see that both `len` and `str` are called 100k times each which makes for about twice as many total function calls in the second case.