First, it's written.
Filter (lambda : True if keyword in. decode (' UTF8 ') else False, alls)
Run cost S, too slow
Change to see
Filter (lambda : True if keyword in. decode (' UTF8 ') Else False, Alls.read (). Split (' \ n '))
Not very good, is the list traversal too slow to change to a tuple
Filter (lambda : True if keyword in. decode (' UTF8 ') Else False, (. Strip () as in alls))
Still, it's not improving.
At this time saw Decode, is it the speed of the drag down? Do not think, because the system function call is not too slow it, change to see it
Filter (lambda : True if keyword in else False, Alls.read (). Decode (' UTF8 '). Split (' \ n '))
Fast, 8 S is over, and sure enough. The call function has a great effect on speed.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Python handles text a code optimization process