#coding=utf8 import cStringIO import StringIO import time values = [] items = ['1,2,31,2,31,2,31,2,3'] * 10000000 #print items st = float(time.time()) for i in items: values.append(i) news = ''.join(values) print len(news) print 'list append cost time:%s'%(float(time.time()) - st) strio = cStringIO.StringIO() st = float(time.time()) for j in items: strio.write(j) print len(strio.getvalue()) print 'cStringIO cost time:%s'%(float(time.time()) - st) strio = StringIO.StringIO() st = float(time.time()) for j in items: strio.write(j) print len(strio.getvalue()) print 'StringIO cost time:%s'%(float(time.time()) - st)