Can I join lists with sum()?
<p>Is it pythonic to use <code>sum()</code> for list concatenation?</p>

<pre><code>&gt;&gt;&gt; sum(([n]*n for n in range(1,5)),[])
[1, 2, 2, 3, 3, 3, 4, 4, 4, 4]
</code></pre>

<p>No, this will get very slow for large lists. List comprehensions are a far better option.</p>

<p>Code for timing list flattening via list comprehensions, summation and itertools.chain.from_iterable:</p>

<pre><code>import time
from itertools import chain

def increasing_count_lists(upper):
    yield from ([n]*n for n in range(1,upper))

def printtime(func):
    def clocked_func(*args):
        t0 = time.perf_counter()
        result = func(*args)
        elapsed_s = time.perf_counter() - t0
        print('{:.4}ms'.format(elapsed_s*1000))
        return result
    return clocked_func

@printtime
def concat_list_sum(upper):
    return sum(increasing_count_lists(upper), [])

@printtime
def concat_list_listcomp(upper):
    return [item for sublist in increasing_count_lists(upper) for item in sublist]

@printtime
def concat_list_chain(upper):
    return list(chain.from_iterable(increasing_count_lists(upper)))
</code></pre>

<p>And running them:</p>

<pre><code>&gt;&gt;&gt; _ = concat_list_sum(5)
0.03351ms
&gt;&gt;&gt; _ = concat_list_listcomp(5)
0.03034ms
&gt;&gt;&gt; _ = concat_list_chain(5)
0.02717ms
&gt;&gt;&gt; _ = concat_list_sum(50)
0.2373ms
&gt;&gt;&gt; _ = concat_list_listcomp(50)
0.2169ms
&gt;&gt;&gt; _ = concat_list_chain(50)
0.1467ms
&gt;&gt;&gt; _ = concat_list_sum(500)
167.6ms
&gt;&gt;&gt; _ = concat_list_listcomp(500)
8.319ms
&gt;&gt;&gt; _ = concat_list_chain(500)
12.02ms
</code></pre>

python