Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

1 + 1 = 3, for large values of 1.


devel / comp.lang.python / Re: tail

SubjectAuthor
o Re: tailMarco Sulla

1
Re: tail

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

  copy mid

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

  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: Sat, 23 Apr 2022 22:41:18 +0200
Lines: 37
Message-ID: <mailman.218.1650746517.20749.python-list@python.org>
References: <CABbU2U98YKdcnJkDPfzE3Pqso+6LL72usB8hrSBVR0WbhauRoQ@mail.gmail.com>
<CAPTjJmr3AiCyvxXt=-nqNLrJfyQHmG=pvSsM7nU_XxhSe94zgA@mail.gmail.com>
<CABbU2U8TAvy0zMhUcNtTD0=WpQ6oNYEeZQuKDjnxhG85FVriDg@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de rBikJICEd6m3C0mB5Qv62Q7i+EviAApJTQlnvvmkZguA==
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=CqoMw2VN;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2022': 0.05; 'sun,': 0.07;
'angelico': 0.09; 'byte': 0.09; 'cc:addr:python-list': 0.09;
'general,': 0.09; 'minus': 0.09; 'received:209.85.219': 0.09;
'threshold': 0.09; 'steps': 0.11; '"end': 0.16; 'bottom?': 0.16;
'cc:name:python list': 0.16; 'characters.': 0.16; 'commons': 0.16;
'encoding.': 0.16; 'from:name:marco sulla': 0.16; 'general.':
0.16; 'indeed': 0.16; 'received:209.85.219.177': 0.16; 'received
:mail-yb1-f177.google.com': 0.16; 'stdlib.': 0.16; 'streams':
0.16; 'wrote:': 0.16; 'problem': 0.16; 'instead': 0.17;
'probably': 0.17; 'cc:addr:python.org': 0.20; 'basically': 0.22;
'sat,': 0.22; 'lines': 0.23; 'cc:2**0': 0.25; 'binary': 0.26;
'done': 0.28; 'chris': 0.28; 'wondering': 0.31; 'think': 0.32;
'split': 0.32; 'message-id:@mail.gmail.com': 0.32; 'but': 0.32;
"i'm": 0.33; 'there': 0.33; 'same': 0.34; '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; 'read': 0.38;
'received:209': 0.39; 'quite': 0.39; 'text': 0.39; 'this,': 0.39;
'use': 0.39; 'difficult': 0.40; 'file:': 0.40; 'seeking': 0.40;
'best': 0.61; 'method': 0.61; 'skip:r 20': 0.64; 'introducing':
0.64; 'less': 0.65; 'matter': 0.68; 'only.': 0.69; 'yourself':
0.75; 'seek': 0.81; 'position': 0.81; 'lines,': 0.84; 'preceding':
0.84; 'sulla': 0.84
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=xX51+Lwq7UK1DR/wiCBfaG9PSOFtDOl57hlUxau76xc=;
b=CqoMw2VN6TU2xH3ZrrazOeleEBPxgv7D9lUeOXjPX7G5+c2pgdtuMp6aOKmKVH2jHq
rqRSZC9733sabPZyplOZONSw/VZYpwGUFXgSnnjRCxmJv8LVCY2eoFPYjhXXb2oP+QLo
BJpXT43MeCxpRY3g2iZXF3hvqMWCcvaALDLdR2z4lRL8++QTCQyWBnF0JP7FRLuBy9SS
NrvUDIo5bfRsBMRItqUI3YbwNnMGDkmjMkhXNstpZsMzOZoWmI4fv6KELFacHQJY64Ad
NuNQ2wgdkxIlRoTeFlPDuOL6lDwOTO7k7An4CBfQzA/BrMrSVSMYnyq1kD5lEZPeAIgY
xklw==
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=xX51+Lwq7UK1DR/wiCBfaG9PSOFtDOl57hlUxau76xc=;
b=e5DjSoLA2mvA63XZuI0+9KbCpkRNFgApp5eUhR5/79UpIjzUmiAY/xlPZ9t475XbwT
RVl5oMtBHWhUArTOcqSaADetKrfhRxN4OjqAEAFtSSpK7q2zFOdDR71r1WiJRIOcD3I8
v557P2hI3jYW6wCNqHn6abucveObLuDajAnm2/YmixjHBoHpJ5XV891vR+cdMMmvphLJ
9UvIBeKpEnBAq2IwtdOvRgn7gKI1br50vNw9p0MfjHx6uvgjr448Ml6SAvxpjbAk9/+f
WIuHQThTIaTjdbaS7rVnOlYbFazA0Hvq5S+rHtxWZnnUQ9V+kdTRx8Mx41uz6kd2ssJd
tpyw==
X-Gm-Message-State: AOAM5323FjBeKl570AC/cmHbZBy00Rhc9S+GQQUHlDBIflJ7Jc3A/oPM
CFs7fELjKltx6gTB5tGLEcBt6Cr4RnXQ3H+eylaMFBGl
X-Google-Smtp-Source: ABdhPJzlRxMpeM/3Zv1aTCU+W8AokK8pLuG1LfigrxBgOc7bxpGgEuBtkyfL+npl9cLNE4uxMgyakwSnaJEljplbV3Y=
X-Received: by 2002:a25:9843:0:b0:641:ce37:c148 with SMTP id
k3-20020a259843000000b00641ce37c148mr10305620ybo.119.1650746514669; Sat, 23
Apr 2022 13:41:54 -0700 (PDT)
In-Reply-To: <CAPTjJmr3AiCyvxXt=-nqNLrJfyQHmG=pvSsM7nU_XxhSe94zgA@mail.gmail.com>
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: <CABbU2U8TAvy0zMhUcNtTD0=WpQ6oNYEeZQuKDjnxhG85FVriDg@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U98YKdcnJkDPfzE3Pqso+6LL72usB8hrSBVR0WbhauRoQ@mail.gmail.com>
<CAPTjJmr3AiCyvxXt=-nqNLrJfyQHmG=pvSsM7nU_XxhSe94zgA@mail.gmail.com>
 by: Marco Sulla - Sat, 23 Apr 2022 20:41 UTC

On Sat, 23 Apr 2022 at 20:59, Chris Angelico <rosuav@gmail.com> wrote:
>
> On Sun, 24 Apr 2022 at 04:37, Marco Sulla <Marco.Sulla.Python@gmail.com> wrote:
> >
> > What about introducing a method for text streams that reads the lines
> > from the bottom? Java has also a ReversedLinesFileReader with Apache
> > Commons IO.
>
> It's fundamentally difficult to get precise. In general, there are
> three steps to reading the last N lines of a file:
>
> 1) Find out the size of the file (currently, if it's being grown)
> 2) Seek to the end of the file, minus some threshold that you hope
> will contain a number of lines
> 3) Read from there to the end of the file, split it into lines, and
> keep the last N
>
> Reading the preceding N lines is basically a matter of repeating the
> same exercise, but instead of "end of the file", use the byte position
> of the line you last read.
>
> The problem is, seeking around in a file is done by bytes, not
> characters. So if you know for sure that you can resynchronize
> (possible with UTF-8, not possible with some other encodings), then
> you can do this, but it's probably best to build it yourself (opening
> the file in binary mode).

Well, indeed I have an implementation that does more or less what you
described for utf8 only. The only difference is that I just started
from the end of file -1. I'm just wondering if this will be useful in
the stdlib. I think it's not too difficult to generalise for every
encoding.

> This is quite inefficient in general.

Why inefficient? I think that readlines() will be much slower, not
only more time consuming.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor