How to remove subset from a file efficiently?

fynali iladijas at gmail.com
Sat Jan 14 02:27:43 EST 2006


    --
    $ ./cleanup.py
    Traceback (most recent call last):
      File "./cleanup.py", line 3, in ?
        import itertools
    ImportError: No module named itertools

    --
    $ time ./cleanup.py
      File "./cleanup.py", line 8
        outfile.writelines(number for number in postpaid_file if number
not in barred)
                                    ^
    SyntaxError: invalid syntax

The earlier results I posted were run on my workstation which has
Python 2.4.1,

    $ uname -a && python -V
    Linux sajid 2.6.13-15.7-smp #1 SMP
    Tue Nov 29 14:32:29 UTC 2005 i686 i686 i386 GNU/Linux
    Python 2.4.1

but the server on which the actual processing will be done has an older
version )-:

    $ uname -a && python -V
    Linux cactus 2.4.21-20.ELsmp #1 SMP
    Wed Aug 18 20:46:40 EDT 2004 i686 i686 i386 GNU/Linux
    Python 2.2.3

Is a rewrite possible of Raymond's or Fredrik's suggestions above which
will still give me the time saving made?

--
fynali




More information about the Python-list mailing list