Dasn wrote:

> # size of 'dict.txt' is about 3.6M, 154563 lines
> f = open('dict.txt', 'r')

> lines = f.readlines()
 
> def sp0(lines):
>         """====> sp0() -- Normal 'for' loop"""
>         l = []
>         for line in lines:
>                 l.append(line.split('\t'))
>         return l

Where do you get the data from in the "real world"? If it's a file you might
get the best overall performance if you skip the readlines() call:

sp0(f)

Anyway, here's another variant you can try:

from itertools import izip, starmap, repeat

def splitlines(lines):
    return list(starmap(str.split, izip(lines, repeat("\t"))))

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to