From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: master 4b79c80c999 1/2: New function 'sort-on' Date: Mon, 5 Feb 2024 17:29:33 +0200 Message-ID: <74cde757-85a1-42ae-b497-bdda737634c0@gutov.dev> 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> <86le7z0yqh.fsf@gnu.org> <005a364e-5058-42ae-b679-96dc046dccea@gutov.dev> <86il330wxa.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39842"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: yuri.v.khan@gmail.com, michael_heerdegen@web.de, jwiegley@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Feb 05 16:30:57 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 1rX0vv-000A5l-GW for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Feb 2024 16:30:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rX0uo-0005AR-Ih; Mon, 05 Feb 2024 10:29:46 -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 1rX0un-0005AJ-KA for emacs-devel@gnu.org; Mon, 05 Feb 2024 10:29:45 -0500 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rX0uj-00083r-A6; Mon, 05 Feb 2024 10:29:44 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 8721A3200ABA; Mon, 5 Feb 2024 10:29:37 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Feb 2024 10:29:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1707146977; x=1707233377; bh=aCIGNkdR1bf8pmWpe9fB+EtnIegye/fs8UF4qaBOjHI=; b= Hsz1KLy8AZJcXv00QAdfwPh/IVkYLlPdoL9L+JJxQUoTO83g4wflHDrnfuxJqNxV 1bQWwEV3X8C36vnItFS7TMBCvxWC3jc8DymnpP/M5IFbj6x8CkK3RJqFWaqX0CW2 rPV0bPBhi3ErkdEHgfo0aGY2mh3cATQ+qnwj4DgiFJiI367eV+ncA3VaXRQtcaa5 ys98HBuZ54z7LV/EEn9qd4Y7B/LcKei6eiO6B0cQJkeuRqoV0RgkwfLipOhRCT9+ JImJq18MR8Qg3EBSdElGv8dS48IvhPT84q/VPt/SMdCTDKLN3IciWoEm4CBSNfci 3pMw+OD6p4fjJSkG45eYew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1707146977; x= 1707233377; bh=aCIGNkdR1bf8pmWpe9fB+EtnIegye/fs8UF4qaBOjHI=; b=S WniUb2VxPOME8r7LEz27DRqUIh7YiowOeoLh14FyYJwGjOe1aR58oD3x2UKPgIur tqhAbEDzIQY34LfZkcmlzuNRwyumeZVzj9s4tQNhhNcdu0vA1bcj3Bbn6+kHO235 0NgjOAVL4OawGOccTcuESX5X2oohTuZpD7so3oHMJQzqFNmR+MpALRnGOPyyoP50 MFRNgmMEBrXJFys2VTBlD7bl9GD9cDVDMnNr/9JuFzCY+a8/oPfBMYC5exzKEBeX T5tdYulLTbn1g8BB6mRmTadyozMnNbXIuwVIUlKJW8Ab94AEHFEQY4dH7bPsZzt2 MVm7q25tFXjlZi/6OLZ6w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedvtddgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepteduleejgeehtefgheegjeekueehvdevieekueeftddvtdevfefhvdevgedu jeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Feb 2024 10:29:35 -0500 (EST) Content-Language: en-US In-Reply-To: <86il330wxa.fsf@gnu.org> Received-SPF: pass client-ip=64.147.123.20; envelope-from=dmitry@gutov.dev; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_SBL_A=0.1 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:315898 Archived-At: On 05/02/2024 17:10, Eli Zaretskii wrote: >> Date: Mon, 5 Feb 2024 16:47:39 +0200 >> Cc: yuri.v.khan@gmail.com, michael_heerdegen@web.de, jwiegley@gmail.com, >> emacs-devel@gnu.org >> From: Dmitry Gutov >> >> On 05/02/2024 16:31, Eli Zaretskii wrote: >>>> 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). >> >> You can't document something that's not in the tree. > > You can't say something is not in the tree when it is. Let me reiterate. I suggest we replace the new addition (sort-on) with a new optional parameter in the 'sort' function. We'll move and adapt the logic which will be used when the said parameter is passed in (non-nil). As a result the new functionality is easier to discover and will be faster in certain cases as well (right now sort-on does some unnecessary copying).