From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Mastro Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Elpa: Pinpoint semantics of `seq-subseq' for streams Date: Wed, 14 Sep 2016 17:51:05 -0700 Message-ID: References: <87bmzrahvg.fsf@web.de> <79c6ccd6-9808-f4fd-071a-58559f72ecdc@gmail.com> <8737l3a4ab.fsf@web.de> <27962aa1-ae40-99f8-64ad-ae21012fb36e@gmail.com> <87vaxywmh9.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1473900797 11165 195.159.176.226 (15 Sep 2016 00:53:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Sep 2016 00:53:17 +0000 (UTC) Cc: Michael Heerdegen , =?UTF-8?B?Q2zDqW1lbnQgUGl0LS1DbGF1ZGVs?= To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 15 02:53:13 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkKvE-000125-74 for ged-emacs-devel@m.gmane.org; Thu, 15 Sep 2016 02:53:00 +0200 Original-Received: from localhost ([::1]:59372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkKvC-0003Jg-9R for ged-emacs-devel@m.gmane.org; Wed, 14 Sep 2016 20:52:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkKv6-0003JY-AH for emacs-devel@gnu.org; Wed, 14 Sep 2016 20:52:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkKv2-00050S-BQ for emacs-devel@gnu.org; Wed, 14 Sep 2016 20:52:51 -0400 Original-Received: from mail-yw0-f196.google.com ([209.85.161.196]:36653) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkKv2-0004wF-79 for emacs-devel@gnu.org; Wed, 14 Sep 2016 20:52:48 -0400 Original-Received: by mail-yw0-f196.google.com with SMTP id v2so2179386ywg.3 for ; Wed, 14 Sep 2016 17:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=p4FkzIDLfN4QYyX5FSnnp694Cgzn4RLlmEBAGB1ETSc=; b=jaFinNf7JSmYEV/SCco0D6dAJ3LPGqzPT3ANEHGz4ZywDXzhsykW7P0BcNvVBo+s6u Q7vXbMkwQtMCPifoRxPd7JIqAe6hVuucXqjhjy0ajwnV5s/3gjfExr59vJeVTQKk6h8f dsB1WCmPalRACxlWi1gJCt8LMUig65B8++l4LcZnawuitzVhHPTUXfwJzeBLIfPB2kOJ 8fpEaL2zyei0E8/I+haAuVZkghX2yDfF1CcrkC6w+/Xe8C7ZuzaaPSwomXzfchPmRbOz LK8eUAi9F4DIMcU5c/xUJ/KhUysMgjW02/vHuasb8DxhahLhUk0DIMVPAtGIcMNl855F e8jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=p4FkzIDLfN4QYyX5FSnnp694Cgzn4RLlmEBAGB1ETSc=; b=MovLsOqpyzfEBRa0YOSZhu8yWPW19Rat4JGogcTgwGdyscrj9pZFOv58Bne8yEV5ZD 8Xnsj0RhCSjh4LBy1Le6MVJlwYl5WYedcurKnxp0CV4+jUM88HsC4510mQL1nGMxk9BY 2O9EBDv0dfbayljygjrrrKfumLufSS+Xo3WMxwdXvor3vVcugFmKF4vxA9VrVECkZ7tI H5t4u79tD/QpwrllL/WvV5kq59ex+78md5gZZzLOlmPrKECJ0TgoGjFsiuayX1F0oriU 5SHDujG8UaeDnlU+gDGJAyTIJc5gg/q5BkbYCC0g8dc+sZIZL0TGFheTPaBMBWuaka/v NqlQ== X-Gm-Message-State: AE9vXwNkxfl0lSo+ctobH4YJiGu7nFt51cZjxKWm1y09yNqTRo0uI0ELJq4+AUrXdCMEFFrlAaNdk3e10YtIrg== X-Received: by 10.129.40.146 with SMTP id o140mr5572358ywo.99.1473900686541; Wed, 14 Sep 2016 17:51:26 -0700 (PDT) Original-Received: by 10.37.58.71 with HTTP; Wed, 14 Sep 2016 17:51:05 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.161.196 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207436 Archived-At: Cl=C3=A9ment Pit--Claudel wrote: >> I think this is actually a very good example why it is good to >> forbid negative indexes. If you are interested in the last n lines >> of a file, why would you dissect the complete file (or buffer) into >> lines and throw away nearly all of the result? > > Because it's much more memory-efficient, as long as the file's lines > are short :) Note that I was careful to say file, not buffer: I don't > need to load a full file in memory before I start processing its > lines. Same for the output of a running process: if I just want the > last n lines, then accumulating all of the output before going to the > end and looking backwards is extremely inefficient, memory-wise. > Dissecting the output (splitting it on newlines) and using a ring > buffer to keep only the last `n` ones is much better. (Asking for my own edification) Wouldn't finding the last N elements require forcing every thunk in the stream (to find its end), thus using more memory than a linked list with the same contents? As long as you don't "hang on to the head" of the stream, earlier elements could be reclaimed by GC, but the same applies to a list. In short, I find this conversation interesting, but don't quite understand where the memory savings come in :) John