Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
One can also use NumPy's flat:
import numpy as np list(np.array(l).flat)
Edit 11/02/2016: OnlyIt only works when sublists have identical dimensions.
Edit 11/02/2016: Only works when sublists have identical dimensions.
It only works when sublists have identical dimensions.
Performance:
import timeit timeit.Timer( 'import numpy as np; list(np.array(l).flat)', 'l=[[1, 2, 3], [4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7]] * 10000' ).timeit(100)
0.31461596488952637