tail
Cameron Simpson
cs at cskk.id.au
Thu May 19 21:33:29 EDT 2022
On 19May2022 19:50, Marco Sulla <Marco.Sulla.Python at gmail.com> wrote:
>On Wed, 18 May 2022 at 23:32, Cameron Simpson <cs at cskk.id.au> wrote:
>> You're measuring different things. timeit() tries hard to measure
>> just
>> the code snippet you provide. It doesn't measure the startup cost of the
>> whole python interpreter. Try:
>>
>> time python3 your-tail-prog.py /home/marco/lorem.txt
>
>Well, I'll try it, but it's not a bit unfair to compare Python startup with C?
Yes it is. But timeit goes the other way and only measures the code.
Admittedly I'd expect a C tail to be pretty quick anyway. But... even a
small C programme often has a surprising degree of startup these days,
what with dynamicly linked libraries, locale lookups etc etc. Try:
strace tail some-empty-file.txt
and see what goes on. If you're on slow hard drives what is cached in
memory and what isn't can have a surprising effect.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list