标签:
Ned Batchelder - Facts and Myths about Python names and values - PyCon 2015:
https://www.youtube.com/watch?v=_AEJHKGk9ns
Ned Batchelder -- Loop like a native: while, for, iterators, generators :
https://www.youtube.com/watch?v=EnSu9hHGq5o
Transforming Code into Beautiful, Idiomatic Python :
https://www.youtube.com/watch?v=OSGv2VnC0go
之前写了一段python想一下子把十几M文件,读取到内存,然后写了一段这样的代码:
1 totalStr="" 2 line=f.readline() 3 while(line): 4 totalStr += line.strip() 5 line=f.readline()
然后读一个十几M的文件要了十分钟左右吧...[掩面哭]
后来我换成了:
1 totalStrList=[] 2 line=f.readline() 3 while(line): 4 totalStrList.append( line.strip() ) 5 line=f.readline() 6 totalStr = ‘‘.join(totalStrList)
然后用了不到一秒吧.....[再次掩面哭]
标签:
原文地址:http://www.cnblogs.com/blog-of-walker/p/5325319.html