get paid to paste

import itertools

listmerge = lambda lst: list(itertools.chain(*lst))

def test(l1, l2, l3, l4):	
	list_over_9000 = listmerge([l1, [l2, [l3]], l4])

	print "len = %s" % len(list_over_9000)
	
l1, l2, l3, l4 = list(xrange(1000000)), list(xrange(1000000)), list(xrange(1000000)), list(xrange(1000000))
test(l1, l2, l3, l4)



C:\Users\user\Desktop\pff>python -m cProfile list.py
len = 2000002
         7 function calls in 0.342 CPU seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.342    0.342 <string>:1(<module>)
        1    0.150    0.150    0.341    0.341 list.py:1(<module>)
        1    0.189    0.189    0.189    0.189 list.py:3(<lambda>)
        1    0.002    0.002    0.190    0.190 list.py:5(test)
        1    0.001    0.001    0.342    0.342 {execfile}
        1    0.000    0.000    0.000    0.000 {len}
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

Pasted: Jul 4, 2009, 9:24:45 am
Views: 46