From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: master d62766305a: Add `take` and `ntake` (bug#56521) Date: Mon, 18 Jul 2022 13:55:21 +0200 Message-ID: <87mtd6eity.fsf@gmail.com> References: <165807284522.13427.2673143161208860104@vcs2.savannah.gnu.org> <20220717154726.F2455C00095@vcs2.savannah.gnu.org> <87r12ierhi.fsf@gmail.com> <2BF27629-33F1-42CF-95A5-3C2EBD4A0DD1@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12666"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 18 14:13:55 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDPdK-00034L-Uq for ged-emacs-devel@m.gmane-mx.org; Mon, 18 Jul 2022 14:13:54 +0200 Original-Received: from localhost ([::1]:59330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDPdJ-0004rl-0f for ged-emacs-devel@m.gmane-mx.org; Mon, 18 Jul 2022 08:13:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDPLS-0002iA-Vh for emacs-devel@gnu.org; Mon, 18 Jul 2022 07:55:26 -0400 Original-Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:42951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDPLR-0006V8-Hi for emacs-devel@gnu.org; Mon, 18 Jul 2022 07:55:26 -0400 Original-Received: by mail-wr1-x430.google.com with SMTP id bu1so16649500wrb.9 for ; Mon, 18 Jul 2022 04:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=HAbo4GeT2Khqnevg4AlwNNVEQXs8JQ1lumRagj4KNx4=; b=npMAEOVMowO+F1UuHpGz9CNr0o6OUWN6ATRK5mCNIC7FEPKN+HoFGZZU4mzdbKUDue svwb+IcHwWseQFOSZP3dhOodYtVxHibn+V+de+eB5gemRQWQL3WuX5NfqiLCJHp6mIiV fuv7zEMsZEHEBnwSNhmo/0ZR0rKqKyUJ1gbDGgXAPe+fBYQ/OXFo3VUx43Ts/crnKky4 xo4NBOGhG0DA5CjD0ZS0iFsU2To6GgfLUvI8P+w2cDdiGSvzeM0xK6QtScR1oJ/UJADg FXw1T/u/12QD4SAdv7pM8BhMgAHlwm0KX40WKBI8X565qnmpMtcZAUhoF/h7EP9Z4fZW W41Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=HAbo4GeT2Khqnevg4AlwNNVEQXs8JQ1lumRagj4KNx4=; b=qLPOYsQ3odZvsp4nHbMvc0Weg9L7trR4WerB+OKXH3/Cm0QpkbZ8eP98dkdLD+mCbq XhxuK9qBLPnePwLQ18Q4bQRinOhNBAAX+bz8s//MnqplxHVJ9iK7SaXABZ6FukCZwL5O nOMpjCP+CyZdQZt7lqNtZKoEJNm1473fx2eakBmsJKX/IaeE0Z/6K5SmN6F1ncXRWTl7 r8VN5jupO/N6toDw93jCwYFTgGqDVWNzG6N581EF8IIFDXn24ZJihLpS9e1Ujc6fZT8O ZS+5+dAi2Wywga3JGptU68vHis815dOos0f6tiO4ryiHqLTYyFzljwgTnnLeHdAgjRdW BHEQ== X-Gm-Message-State: AJIora9cJavDoI+hkdvQiMZzrqwp5d8fqmInOzprNxi+3F/Kctg8VSZi up14SZ0vXvVD17ddGsX3r1LUf3FttJ4= X-Google-Smtp-Source: AGRyM1uw0ySebUwsqHLRWEyHY+hZEiAHYv42FTHkWU1ZwK8UueC6Pd/Eckjz6iC//r0fdhOwhq6G5g== X-Received: by 2002:a5d:4c88:0:b0:21d:a699:d553 with SMTP id z8-20020a5d4c88000000b0021da699d553mr22507554wrs.344.1658145323522; Mon, 18 Jul 2022 04:55:23 -0700 (PDT) Original-Received: from rltb ([2a01:e0a:3f3:fb50:6792:a1bb:2e4a:e9bc]) by smtp.gmail.com with ESMTPSA id l29-20020a05600c1d1d00b003a2e27fc275sm15572281wms.12.2022.07.18.04.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 04:55:22 -0700 (PDT) In-Reply-To: <2BF27629-33F1-42CF-95A5-3C2EBD4A0DD1@acm.org> ("Mattias =?utf-8?Q?Engdeg=C3=A5rd=22's?= message of "Mon, 18 Jul 2022 12:59:51 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=rpluim@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292234 Archived-At: >>>>> On Mon, 18 Jul 2022 12:59:51 +0200, Mattias Engdeg=C3=A5rd said: Mattias> 18 juli 2022 kl. 10.48 skrev Robert Pluim : >> Does this need the usual blurb to do >>=20 >> (setq list-var (ntake 3 list-var)) >>=20 >> to ensure `list-var' is updated? Mattias> Sort of; I added some text to that effect. Using the return va= lue is only needed if N can be nonpositive. >> I think this would be clearer as >>=20 >> "If N is >=3D the length of LIST, return LIST (or a copy)." >>=20 >> since we=CA=BCre talking about the effect of various values of N. Mattias> Right, it's now been changed to something like that. Thank you! That looks good, thanks Mattias> Now `seq-take` uses `take`, and so does `seq-subseq`. This mad= e both Mattias> faster, but the latter was boosted immensely by not formatting= an Mattias> error string up-front. (meta-comment: you=CA=BCve made a number of speedups recently, it would be great if you could show some numbers of the effects) (meta-meta-comment: this is not a criticism of your work, just a nice-to-ha= ve) Mattias> `seq-subseq` would be even faster if simply written as Mattias> (take (- end start) (nthcdr start sequence)) Mattias> but the interface requirements force a much more cumbersome Mattias> implementation. (And does it really need `copy-sequence`? The = docs are Mattias> unclear.) (info "(elisp) Sequence Functions") says: All functions defined in this library are free of side-effects; i.e., they do not modify any sequence (list, vector, or string) that you pass as an argument. It doesn=CA=BCt say anything about the result not sharing structure with the inputs. Probably code in the wild already implicitly depends on the `copy-sequence', though, so I=CA=BCd think twice before modifying that contract. Robert --=20