preallocate list

peufeu at free.fr peufeu at free.fr
Wed Apr 13 10:57:21 EDT 2005


what about :

factors = [map(float, line.split()) for line in file]

should be a hell of a lot faster and nicer.

>              for line in f:
>                  factor = []
>                  tokens = line.split()
>                  for i in tokens:
>                      factor.append(float(i))
>                  factors.append(factor)
>
> Is this nasty?
>
> Jim




More information about the Python-list mailing list