dict is really slow for big truck

pruebauno at latinmail.com pruebauno at latinmail.com
Wed Apr 29 19:41:46 CEST 2009


On Apr 29, 1:05 pm, Scott David Daniels <Scott.Dani... at Acm.Org> wrote:
> Bruno Desthuilliers wrote:
> > d = {}
> > for line in open(thefile):
> >    arr = line.strip().split()
> >    d[arr[0]] = arr
>
> Sorry, not picking on Bruno in particular, but I keep seeing
> this formulation around various places.
> When does line.strip().split() ever differ from line.split()?
>
> --Scott David Daniels
> Scott.Dani... at Acm.Org

They don't.
It is probably out of habit of using the generalized idiom:
>>> line="a,b,c\n"
>>> line.strip().split(",")
['a', 'b', 'c']
>>> line.split(",")
['a', 'b', 'c\n']



More information about the Python-list mailing list