Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The test of intelligent tinkering is to save all the parts. -- Aldo Leopold


devel / comp.lang.python / Re: tail

SubjectAuthor
o Re: tailChris Angelico

1
Re: tail

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Sun, 24 Apr 2022 21:32:11 +1000
Lines: 28
Message-ID: <mailman.238.1650799945.20749.python-list@python.org>
References: <CABbU2U98YKdcnJkDPfzE3Pqso+6LL72usB8hrSBVR0WbhauRoQ@mail.gmail.com>
<CAPTjJmr3AiCyvxXt=-nqNLrJfyQHmG=pvSsM7nU_XxhSe94zgA@mail.gmail.com>
<25955416-d16e-2ac3-3fc9-d0dba80b61cd@vub.be>
<CAPTjJmpZmGMwFqu9kNmYmN3YfakcPRnQjFN1n++-iJS-rS0L3w@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 4X29N3lYG1JbvnseMGoeDgtgMeS8soTqbGFO7MnoNSuA==
Return-Path: <rosuav@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=gh88f1dq;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.022
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '2022': 0.05; 'sun,': 0.07;
'memory.': 0.09; 'antoon': 0.16; 'bottom?': 0.16; 'chrisa': 0.16;
'commons': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'iterate': 0.16; 'pardon': 0.16; 'schreef': 0.16;
'streams': 0.16; 'wrote:': 0.16; "can't": 0.17; 'to:addr:python-
list': 0.20; 'lines': 0.23; 'python,': 0.25; 'chris': 0.28;
'split': 0.32; 'message-id:@mail.gmail.com': 0.32; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'received:209.85': 0.37; 'file':
0.38; 'read': 0.38; 'received:209': 0.39; 'quite': 0.39; 'text':
0.39; 'block': 0.39; 'still': 0.40; 'done.': 0.40; 'method': 0.61;
'skip:r 20': 0.64; 'introducing': 0.64; 'entire': 0.67;
'backwards': 0.84; 'decode': 0.84; 'easy.': 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;
bh=Y59/6k+gPQFWMwHL8d9QAqfnfnKpdBiu3tmdrQNF/no=;
b=gh88f1dqLkNK0UR7uvaa0ZVuRRwb+SxnVn6ZjuDRSlJyRh1q0wb5r2bs59DWHTqz8T
08+l9JGxeM5K18J40zio42kYajYfufLlVcE8XgBnsm5eDchhIkTtRGiAxlz5r+IDA4pc
9xpVVsM23Xo/fE8GqB5yD0yGh+3G7cVOCW4vnXtvXOjq/9y3Jjae3t4pB98TOniRRqOL
JZuYXk21GiOhRc8Aqrv7jkuXTRMZrShvxauTlYfYxhKfw6ynOosmzwFJlviOw9bD0+0Y
2tJGESCY+56zKU8DJWeEo+LDtIcf/vePqKSwXP2upRqUBL567m2emqMmjQtZIPrejG3V
TJJg==
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=Y59/6k+gPQFWMwHL8d9QAqfnfnKpdBiu3tmdrQNF/no=;
b=vbtNuC3crYqbZdvGiuyDPRqNTa8j4oFtrWErkm8OGwpVdJQ4j00Ze/Au/HZyL9pO+3
Mkmm7dEgvstr67hM1nxfIHbcI/hA4mbnghs8DyyPR8QqcLcl1NwvH8cA2VKuO0YHkWMS
fNDkrzfU6jtNSk9/I6Tizd9aCKGojpjhA1XmWXELqGIqaU1yPqJbjOGcp0LurkE1nBY+
omodJ04Xf9OBOudR8BUuztAls+8GJUmV+DYdvCIAFZsMjy6cOwv6/YiiE6OXlokO1+gC
zRwyiYIMoWWAkPYuGYhVW6QsWswnrxx/200F4O/doXYXIK1HyXdNLF4eOGknoYsjyC5H
NQng==
X-Gm-Message-State: AOAM533HsH8mwYk+CD2gXuIu5NJhuw2u0p7SR+BUIUQcCn2nGWrXS8qt
R3pJwcg5CCUcrEEFvemDXb1cis1md93BAyGhTr9pjitz
X-Google-Smtp-Source: ABdhPJzZvx0EZU7S52TN4UXUst086iyV8txEyHki9G9obsoqI+2PxfyOvkN8W5v4FULwLIwiqauLAmV2i/TBkBB1NQo=
X-Received: by 2002:a5d:6da8:0:b0:20a:9377:c389 with SMTP id
u8-20020a5d6da8000000b0020a9377c389mr10836350wrs.495.1650799943209; Sun, 24
Apr 2022 04:32:23 -0700 (PDT)
In-Reply-To: <25955416-d16e-2ac3-3fc9-d0dba80b61cd@vub.be>
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: <CAPTjJmpZmGMwFqu9kNmYmN3YfakcPRnQjFN1n++-iJS-rS0L3w@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U98YKdcnJkDPfzE3Pqso+6LL72usB8hrSBVR0WbhauRoQ@mail.gmail.com>
<CAPTjJmr3AiCyvxXt=-nqNLrJfyQHmG=pvSsM7nU_XxhSe94zgA@mail.gmail.com>
<25955416-d16e-2ac3-3fc9-d0dba80b61cd@vub.be>
 by: Chris Angelico - Sun, 24 Apr 2022 11:32 UTC

On Sun, 24 Apr 2022 at 21:11, Antoon Pardon <antoon.pardon@vub.be> wrote:
>
>
>
> Op 23/04/2022 om 20:57 schreef Chris Angelico:
> > 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.
> >
> > 1) Read the entire file and decode bytes to text
> > 2) Split into lines
> > 3) Iterate backwards over the lines
> >
> > Tada! Done. And in Python, quite easy. The downside, of course, is
> > that you have to store the entire file in memory.
>
> Why not just do:
>
> tail = collections.deque(text_stream, maxlen = nr_of_lines)
> tail.reverse()
> ...
>

You still need to read the entire file, and you also restrict the max
line count, so you can't iterate this to take the next block of lines.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor