Help optimize a script?

Markus Schaber use-net at schabi.de
Wed Oct 17 18:13:07 EDT 2001


Hi,

there already were good suggestions, but I have another to add:

On Wed, 17 Oct 2001 10:51:51 -0700, Joseph Santaniello
<someone at _no-spam_arbitrary.org> wrote:

> # while is used cuz line in readlines() used too much ram with
> # huge files.

ind = indecies[sys.argv[1]]

> while 1:
>         line = sys.stdin.readline()
>         if not line:
>                 break
>         new = ''
>         start = 0

          for index in ind:

>                 new = new + string.strip(line[start:start +
>                 index])+'\t' start = start + index
>         print new

This pulls the double indexing and lookup of three names into the lookup of one name for every line. Only a small improvement, but it should be measurable :-)

markus

-- 
You don't have to be Microsoft to suck... but it helps.
(Tim Hammerquist in comp.lang.python)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20011018/de6a2964/attachment.sig>


More information about the Python-list mailing list