Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

There are bugs and then there are bugs. And then there are bugs. -- Karl Lehenbauer


devel / comp.lang.python / Re: tail

SubjectAuthor
o Re: tailMarco Sulla

1
Re: tail

<mailman.444.1652890282.20749.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18318&group=comp.lang.python#18318

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Marco.Su...@gmail.com (Marco Sulla)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Tue, 17 May 2022 22:45:34 +0200
Lines: 29
Message-ID: <mailman.444.1652890282.20749.python-list@python.org>
References: <CABbU2U9HHADoY9ysgtoBtPnyu7UEaozCayuRRbc7UaVZPnvCLw@mail.gmail.com>
<Yn2KOYsmP0Zce8GT@cskk.homeip.net>
<CABbU2U-qtrhRs_T19aQ1MC0mkaJ12aDq=j3ce433259w8SiUQA@mail.gmail.com>
<Yn43K7X4E1PHbvW5@scrozzle>
<CABbU2U_O-wAdp=JvEHKhfNF=faDvo3bbrUtX6c7ZpBn__mG4Nw@mail.gmail.com>
<CABbU2U_DbdMt7578cqAuHjyRpe=3cW29aog0=OJJZRkX8-Xi6g@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de ua7OzzxemJZKJ9vv09zKHAZ32qFsGQwGWjvXMScNn70Q==
Return-Path: <elbarbun@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=onQq2hul;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: UNSURE 0.238
X-Spam-Level: **
X-Spam-Evidence: '*H*': 0.54; '*S*': 0.01; 'linux': 0.09;
'from:name:marco sulla': 0.16; 'seconds.': 0.16; 'to:addr:python-
list': 0.20; "i've": 0.22; 'maybe': 0.22; 'seems': 0.26; 'done':
0.28; '>>>': 0.28; 'wrong': 0.28; 'received:209.85.210': 0.29;
'message-id:@mail.gmail.com': 0.32; 'skip:2 10': 0.32; 'but':
0.32; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; "it's": 0.37; 'received:209.85':
0.37; 'file': 0.38; 'thanks': 0.38; 'received:209': 0.39; 'quite':
0.39; 'text': 0.39; 'me.': 0.62; 'skip:t 40': 0.64; 'result,':
0.69; 'skip:t 60': 0.70; 'performance': 0.71; 'surprise': 0.76;
'1.3': 0.84; 'good,': 0.84; 'me:': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=ubZKsyT6p65WMkETKQvG7WEnfcDykbJV/DXCAC1gcd8=;
b=onQq2hulmWwhARgRgQas8fKRZdS75XrtOVKHK1vpaVhZF3jCdVsNV4nteXIZx1DTA2
oEoafu04JHgg3O35LoqXCLQZRbpDhuMfmfmPYJfQ3nBmQnV0Y4Yz4AUtSqmIPB86TO4v
amSnIWOoSUA9Dy1bwwj1mwZLtt+hKZvnIxVs1zjBipSjsm6vMNzz48TlPnFzHjtCDHtU
T6enqsIQQctJTMz82JETfSkvSqaSlL0uHdtPfYzq31zSnkT8EYC7q+RoaRt0i/PKzQRp
y+Z+peFQ/Ya5/RoSVIoRpjuXss6U3oQZB5cWN0zqg4zqPf3Oz1jkzqfv9W389ZLzCErv
t61A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=ubZKsyT6p65WMkETKQvG7WEnfcDykbJV/DXCAC1gcd8=;
b=hggQEnw9YLOv74uj3zXlC/ZkAkENu628s46kyy2BQGAkoiZDfc6n2Cfb7KEEWlegU5
eOVDlMJQCQ0SHgq9RU8Zex2YR5to2Dzjxoqzz/EIL0pfqZgS9gxMwdM84MBGSGiyCkI4
2gZKA2yZHxxbkZzTk5yz4s5CKl6mquyTXPY061hXbIcURKqota1zzg6QRMuuV/MhyBPq
Fx0TWyOLfo4i6ubW3Xm2gHbmccrOr+19mjJeHYjwzmFrX0SOmiJfyrSRz4D39jp3/tvk
zl69NRY/ozMFq+YFX3J1Z2qFv2bGhWag8Bss81FHOQCaibi62HgzNrXqYgM1SbW/Kl/f
kepg==
X-Gm-Message-State: AOAM530aZ7x0ocOLQiOomrlfRvPMTpfY4PqFkyWE4u2leuZz470dssIF
zzS3+i7sDFyK+eMrGj0ctNk4MXCmyeV4kzgcBjBb/kKVqE0=
X-Google-Smtp-Source: ABdhPJwfAhtE98AXTNe+vL/3PFnHg2v+4f7qYr7a191ela5jolmvxjCYtgCZ6ztBA3b2SrAyjEn+MekS2k5KXmtiMg4=
X-Received: by 2002:a05:6830:23b9:b0:606:d416:aaed with SMTP id
m25-20020a05683023b900b00606d416aaedmr8557815ots.89.1652820371626; Tue, 17
May 2022 13:46:11 -0700 (PDT)
In-Reply-To: <CABbU2U_O-wAdp=JvEHKhfNF=faDvo3bbrUtX6c7ZpBn__mG4Nw@mail.gmail.com>
X-Mailman-Approved-At: Wed, 18 May 2022 12:11:21 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CABbU2U_DbdMt7578cqAuHjyRpe=3cW29aog0=OJJZRkX8-Xi6g@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U9HHADoY9ysgtoBtPnyu7UEaozCayuRRbc7UaVZPnvCLw@mail.gmail.com>
<Yn2KOYsmP0Zce8GT@cskk.homeip.net>
<CABbU2U-qtrhRs_T19aQ1MC0mkaJ12aDq=j3ce433259w8SiUQA@mail.gmail.com>
<Yn43K7X4E1PHbvW5@scrozzle>
<CABbU2U_O-wAdp=JvEHKhfNF=faDvo3bbrUtX6c7ZpBn__mG4Nw@mail.gmail.com>
 by: Marco Sulla - Tue, 17 May 2022 20:45 UTC

Well, I've done a benchmark.

>>> timeit.timeit("tail('/home/marco/small.txt')", globals={"tail":tail}, number=100000)
1.5963431186974049
>>> timeit.timeit("tail('/home/marco/lorem.txt')", globals={"tail":tail}, number=100000)
2.5240604374557734
>>> timeit.timeit("tail('/home/marco/lorem.txt', chunk_size=1000)", globals={"tail":tail}, number=100000)
1.8944984432309866

small.txt is a text file of 1.3 KB. lorem.txt is a lorem ipsum of 1.2
GB. It seems the performance is good, thanks to the chunk suggestion.

But the time of Linux tail surprise me:

marco@buzz:~$ time tail lorem.txt
[text]

real 0m0.004s
user 0m0.003s
sys 0m0.001s

It's strange that it's so slow. I thought it was because it decodes
and print the result, but I timed

timeit.timeit("print(tail('/home/marco/lorem.txt').decode('utf-8'))",
globals={"tail":tail}, number=100000)

and I got ~36 seconds. It seems quite strange to me. Maybe I got the
benchmarks wrong at some point?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor