From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: Pattern matching on match-string groups #elisp #question Date: Sun, 28 Feb 2021 14:46:42 +0100 Message-ID: <62A88DEE-5BFD-4479-AB15-1A43DC2B299D@acm.org> References: <87v9agxkld.fsf@tcd.ie> <80CE2366-76F4-4548-B956-F16DFCE23E4C@acm.org> <258C930A-B183-4211-9917-0AD96C17A638@acm.org> <288FFC66-E3BE-4E5F-AAD5-309A632F8058@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3752"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Basil L. Contovounesios" , Ag Ibragimov , Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 28 18:26:06 2021 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 1lGPpV-0000rQ-Pk for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Feb 2021 18:26:05 +0100 Original-Received: from localhost ([::1]:60146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGPpU-0003g5-Mq for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Feb 2021 12:26:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGPbg-0007N4-NF for emacs-devel@gnu.org; Sun, 28 Feb 2021 12:11:49 -0500 Original-Received: from mail1436c50.megamailservers.eu ([91.136.14.36]:35908 helo=mail263c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGPbV-0004pR-Ie for emacs-devel@gnu.org; Sun, 28 Feb 2021 12:11:43 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1614520008; bh=zr6CuI8zinDlB2lHjh+qfXPftE/Yt9UAIgX1u04oT8c=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Zkxy+2s7BonIC3YIOlBuogM50XzsjcEVOcSv8UfvLweRirvELActYSmxApxqoxbSv rniY/tPJeY5obrRwPp/gbPS6q3vWoNc0eBBLiGTi74t7ZFI+SA+RP+XPjK1EzsBowS 9riN5bb0jZJi0tgxW93IRYrLHs0Eg2gHPp7Nwsgs= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-b952e353.032-75-73746f71.bbcust.telenor.se [83.227.82.185]) (authenticated bits=0) by mail263c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 11SDkg0R009052; Sun, 28 Feb 2021 13:46:44 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A742F1F.603B9EC8.0002, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=fdHTNHYF c=1 sm=1 tr=0 a=von4qPfY+hyqc0zmWf0tYQ==:117 a=von4qPfY+hyqc0zmWf0tYQ==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=iRZporoAAAAA:8 a=F7FEK1xsdQMOTK6KV0oA:9 a=CjuIK1q_8ugA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-Origin-Country: SE Received-SPF: softfail client-ip=91.136.14.36; envelope-from=mattiase@acm.org; helo=mail263c50.megamailservers.eu X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:265750 Archived-At: 27 feb. 2021 kl. 21.32 skrev Stefan Monnier : >> So where does that leave us with the rx pattern? >=20 > It doesn't affect it directly, except in the fact that the old > definition would now also work for `pcase-let`. Well, the new rx definition is now in place since the old one, and the = even older one in Emacs 26 and earlier, were buggy as you showed. This = means that the 'rx' pattern no longer relies on side-effects being = retained in pcase. I went with dotted lists (a b c . d) because benchmarking showed it to = be faster than either proper lists or vectors, the generated code is = smaller than for lists, and the case of a single variable reduces = naturally to no consing at all. >> I now have, and am sad to say that a list is always faster for any = practical >> number of N (I didn't bother trying more than 30) although the = difference >> narrows as N grows. This is despite the destructuring code becoming >> considerably bigger for lists (as we get a long chain of tests and = branches) >> than for vectors. It all boils down to vector construction being more >> expensive than lists. >=20 > Indeed, I think there's some optimization opportunities in our > implementation of vector construction. We've already improved the > performance significantly compared to Emacs<24, but there's still room > for improvement. Looking a bit closer it gets more nuanced: one reason why (pcase (list 1 2 3) (`(,a ,b ,c) (+ a b c))) is faster than (pcase (vector 1 2 3) (`[,a ,b ,c] (+ a b c))) is that the latter contains three general function calls: to `vector`, = `vectorp`, and `eql` (for checking the length), whereas the list version = has byte-ops for everything.