Reducing cache/buffer for faster display

Rikishi42 skunkworks at rikishi42.net
Thu Sep 27 20:15:25 EDT 2012


On 2012-09-27, Chris Angelico <rosuav at gmail.com> wrote:
> On Fri, Sep 28, 2012 at 7:57 AM, Rikishi42 <skunkworks at rikishi42.net> wrote:
>> I have these 2 scripts that are very heavy on the file i/o, consume a very
>> reasonable amount of cpu and output their counters at a - very - relaxed
>> pace to the console. The output is very simply done using something like:
>>
>>    print "files:", nFiles, "\r",
>>
>>
>> Yet alltough there is no real reason for it, even a pace of a print every
>> 10-30 secs will be cached, only to actually show an output update every 1-2
>> min or so.
>
> Yup! Just add a call to sys.stdout.flush() after each print.

Update: tried it, ran it, I love it.

Thanks !


-- 
When in doubt, use brute force.
                -- Ken Thompson



More information about the Python-list mailing list