FW: "sins" (aka, acknowledged language problems)

Alex Martelli Alex.Martelli at think3.com
Mon Dec 20 03:13:09 EST 1999


> Han-Wen writes:
> 
    def repl(match,dict=dict):
            return eval(match.group(1),dict)
        
    oup.write (re.sub (repl, inp.read()))

> yep, if the input file fits _comfortably_ in memory I can
> slurp it in at one go (although I'd still prefer to loop over
> lines to insert other features, see my more recent post
> about 'critique please') -- I did it with readlines and a for
> loop in my latest version.
> 
> I would still prefer to do sequential processing rather
> than chewing up the memory to hold all of the input
> file at once (in your version, about twice as much
> memory, since output is also prepared in-storage
> then emitted at once), just in case the input file should
> be big (even if only moderately so, consuming lots of
> virtual memory will slow things down horribly).
> 
> And I think it a pity that syntax issues twist my arm
> so noticeably towards changing semantics...:-).
> 
> 
> Thanks for your response, anyway!
> 
> Alex
> 




More information about the Python-list mailing list