Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

C'est magnifique, mais ce n'est pas l'Informatique. -- Bosquet [on seeing the IBM 4341]


devel / comp.lang.python / Re: tail

SubjectAuthor
o Re: tailMarco Sulla

1
Re: tail

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

 copy mid

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

 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: Sun, 24 Apr 2022 17:47:20 +0200
Lines: 24
Message-ID: <mailman.241.1650815279.20749.python-list@python.org>
References: <CABbU2U98YKdcnJkDPfzE3Pqso+6LL72usB8hrSBVR0WbhauRoQ@mail.gmail.com>
<CAPTjJmr3AiCyvxXt=-nqNLrJfyQHmG=pvSsM7nU_XxhSe94zgA@mail.gmail.com>
<CABbU2U8TAvy0zMhUcNtTD0=WpQ6oNYEeZQuKDjnxhG85FVriDg@mail.gmail.com>
<CAPTjJmqnfoPjoNT2CNsrkMVxkzAMHHXHj-G3DuGrJ21SDRNsPA@mail.gmail.com>
<CABbU2U_sWyEmBXf0Psudwc-FLeRYqLX=B4x-_9TV0qc5ZVt3Bg@mail.gmail.com>
<CAPTjJmrJacamKq1V5T8FECkm4jURdYQgj0VsC+JK5Db0NoFaww@mail.gmail.com>
<CABbU2U81bTTtf_5d-drx8kj7VQunPZg8xMATm8FoQ6ONVZULLw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de XSh5GXth7TomrdU2fA5kMwVKZbjbuYSFRWYb5dcOP0cw==
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=PHnlJW87;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.052
X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; '(which': 0.04; '2022':
0.05; 'is.': 0.05; 'angelico': 0.09; 'byte': 0.09; 'cc:addr
:python-list': 0.09; 'cc:name:python list': 0.16; 'from:name:marco
sulla': 0.16; 'newline': 0.16; 'wrote:': 0.16; 'instead': 0.17;
'cc:addr:python.org': 0.20; 'sat,': 0.22; 'cc:2**0': 0.25;
"isn't": 0.27; 'chris': 0.28; 'think': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'really': 0.37; 'using': 0.37; "it's": 0.37; 'received:209.85':
0.37; 'file': 0.38; 'read': 0.38; 'received:209': 0.39; 'single':
0.39; 'seeking': 0.40; 'search': 0.61; 'likely': 0.61; "there's":
0.61; 'once': 0.63; 'full': 0.64; 'times.': 0.64; 'your': 0.64;
'time.': 0.66; 'back': 0.67; 'more,': 0.67; 'time,': 0.67;
'compare': 0.69; "you'll": 0.73; 'line,': 0.93
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
:cc; bh=rUh2K8yYKpX9cRPfnnUz3uF65XLdCg56AqrXI4SPub0=;
b=PHnlJW876awN9oQdJf1x6eSqge7BptYzDsbaMTGSm7i4pgfuNZErCG4MTA7syQnP9d
JcpanL9Xq5NEtk2xKskMVbbWLGC04Ju/D4HowUQZVNJao9wu2yEwe1WvozMCRWDZ7Kja
+1vAiL2dNuY3t9UBhtR+ftXF7WGTIneuEg3Pe1BtvkjJF+HFFQVfbqWZd6qm1tBX6IIN
fee+Pdxu8n+y8j5ARNJSyGAur3vIPg6S/jkXjQovpAVJ39h0ibY5mE9DrlRLLmgGFn2a
5j72zol8gINE6eLMezo9Yk2rpk04hNq5Yr7ToQ2ucqFKgowgEwHSjqJuQ7V5ICOVcBpW
zZoA==
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:cc;
bh=rUh2K8yYKpX9cRPfnnUz3uF65XLdCg56AqrXI4SPub0=;
b=H0L2iPe8pG4h1ftfnx5GWoKsBcek1OU4tbBGwpqWZwoTPpUk3Voca1xh9vCPxAjvus
mjmqyeH/UtDsii99CRGaUyfAyqKoTOwodvp7wiL2d+xOi8pxIJ305rz8sZjkbGlcrPJe
hgUKhN4TMKqqNowjRgZdPnIrTl9l32x42L6TTMtQ4mOlSU59mffm4W8mR8nt0WO0lLt4
bgBSQQQDIcUaLx0WhC9FOryijXPSwkCPGRI9+Y6BEFgDrO/LfPKWu5o2uglD9VxM0waN
WVZzMyrGMC8FlRCRWidVOZgji5TPAR+rE37dmDqRymAMRttQXA8+mVmZV8myichY+w+l
Ab0A==
X-Gm-Message-State: AOAM532Wdo+EH3if8vYmUGekxQAXszQPr3g4ABGSQGaHzaDSHgofJls7
WDwQK9/sXt3c4jrdxUmIMYvAbYA82pzGKSYcZHd7mxhJ
X-Google-Smtp-Source: ABdhPJzDbDTnFlMZUlKKvYZ3VJ4e3yVaBlQl9qcgjZFdCfMo4j/CQy3vbwAHb/JpP9wNxU7iBwsOQ2jLGuQycVCiMsM=
X-Received: by 2002:a0d:c685:0:b0:2ef:6aaf:5358 with SMTP id
i127-20020a0dc685000000b002ef6aaf5358mr12644631ywd.453.1650815277324; Sun, 24
Apr 2022 08:47:57 -0700 (PDT)
In-Reply-To: <CAPTjJmrJacamKq1V5T8FECkm4jURdYQgj0VsC+JK5Db0NoFaww@mail.gmail.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <CABbU2U81bTTtf_5d-drx8kj7VQunPZg8xMATm8FoQ6ONVZULLw@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U98YKdcnJkDPfzE3Pqso+6LL72usB8hrSBVR0WbhauRoQ@mail.gmail.com>
<CAPTjJmr3AiCyvxXt=-nqNLrJfyQHmG=pvSsM7nU_XxhSe94zgA@mail.gmail.com>
<CABbU2U8TAvy0zMhUcNtTD0=WpQ6oNYEeZQuKDjnxhG85FVriDg@mail.gmail.com>
<CAPTjJmqnfoPjoNT2CNsrkMVxkzAMHHXHj-G3DuGrJ21SDRNsPA@mail.gmail.com>
<CABbU2U_sWyEmBXf0Psudwc-FLeRYqLX=B4x-_9TV0qc5ZVt3Bg@mail.gmail.com>
<CAPTjJmrJacamKq1V5T8FECkm4jURdYQgj0VsC+JK5Db0NoFaww@mail.gmail.com>
 by: Marco Sulla - Sun, 24 Apr 2022 15:47 UTC

On Sat, 23 Apr 2022 at 23:18, Chris Angelico <rosuav@gmail.com> wrote:

> Ah. Well, then, THAT is why it's inefficient: you're seeking back one
> single byte at a time, then reading forwards. That is NOT going to
> play nicely with file systems or buffers.
>
> Compare reading line by line over the file with readlines() and you'll
> see how abysmal this is.
>
> If you really only need one line (which isn't what your original post
> suggested), I would recommend starting with a chunk that is likely to
> include a full line, and expanding the chunk until you have that
> newline. Much more efficient than one byte at a time.
>

Well, I would like to have a sort of tail, so to generalise to more than 1
line. But I think that once you have a good algorithm for one line, you can
repeat it N times.

I understand that you can read a chunk instead of a single byte, so when
the newline is found you can return all the cached chunks concatenated. But
will this make the search of the start of the line faster? I suppose you
have always to read byte by byte (or more, if you're using urf16 etc) and
see if there's a newline.

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor