From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master 4b79c80c999 1/2: New function 'sort-on' Date: Mon, 05 Feb 2024 16:31:02 +0200 Message-ID: <86le7z0yqh.fsf@gnu.org> References: <170688047526.14693.2994051491358257471@vcs2.savannah.gnu.org> <20240202132756.4272CC0EFE7@vcs2.savannah.gnu.org> <87cytej4hy.fsf@daniel-mendler.de> <86zfwi52m1.fsf@gnu.org> <87plxe28as.fsf@web.de> <86wmrm50i5.fsf@gnu.org> <3ff9d4cf-7b4f-4924-8663-3f43625760bf@gutov.dev> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4012"; mail-complaints-to="usenet@ciao.gmane.io" Cc: yuri.v.khan@gmail.com, michael_heerdegen@web.de, jwiegley@gmail.com, emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Feb 05 15:32:11 2024 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 1rX014-0000p3-AA for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Feb 2024 15:32:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rX004-0005kJ-M6; Mon, 05 Feb 2024 09:31:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rX002-0005k4-UO for emacs-devel@gnu.org; Mon, 05 Feb 2024 09:31:06 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rX002-0005aQ-4I; Mon, 05 Feb 2024 09:31:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=2avIxTuhbTxtxro/b1ATO/DtYXvKrsW+49pZQGIq7Rg=; b=SfMfnrTrpjZh rtVB2ms6Z3iWSJ771wnmnJpLdCk4jFlij/FC+FzYBlF9/1f3GMlj6CSDbK1AxAaiFdXx0L9r/HFTy lMYjOD/ks4R3e08TQTAHvSN8/pDrPK8/KmLbWT9vb5h11q4KP6VI9PdO2uhTqCy9ld/G1ziXWNr/u RSWZmgGO9apntKs0Uwi6IKGZDWltQgcbcUSNb8iFUL5ZWuyDjyJWvt8n2Fr7CI2vyfFFvQ8h/s4vT auwCNi8K+/8WvAh4vH5Fl1bUBZ2PJGiVx6Dx5kX2vB3N/lj5tVagGu+RygI2HJ2YyZ6hUtDmIsJZQ wOBy4/2NF5SFt/IINi6FmQ==; In-Reply-To: <3ff9d4cf-7b4f-4924-8663-3f43625760bf@gutov.dev> (message from Dmitry Gutov on Mon, 5 Feb 2024 15:25:59 +0200) 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:315891 Archived-At: > Date: Mon, 5 Feb 2024 15:25:59 +0200 > Cc: Eli Zaretskii , Michael Heerdegen > , John Wiegley , > emacs-devel@gnu.org > From: Dmitry Gutov > > On 05/02/2024 07:30, Yuri Khan wrote: > > On Mon, 5 Feb 2024 at 07:49, Dmitry Gutov wrote: > > > >> The result would make it destructive and consequently faster (not > >> entirely non-consing, but close to it--while the current sort-on creates > >> two extra lists of length N), which should fit the original goal: a > >> faster sorting routine then uses ACCESSOR. > > > > Schwartzian transform transforms a sort algorithm that is O(n log n) > > accessor calls + O(n log n) comparison calls into one that is O(n) > > accessor calls + O(n log n) comparison calls. Depending on the > > accessor expensiveness, that may or may not balance out the consing > > and eventual GC. > > Users who don't want to use the transform could inline the accessor > calls into the comparison function instead (as many have done in the > past). So if we document this properly, it should be fine. It's already documented (in the ELisp manual).