From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Change Emacs 'sort' API to use three-way comparison Date: Sat, 30 Aug 2014 16:23:06 +0200 Message-ID: <87r3zyjbud.fsf@building.gnus.org> References: <83fvgfinea.fsf@gnu.org> <5400EE70.8050207@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1409408637 11718 80.91.229.3 (30 Aug 2014 14:23:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 Aug 2014 14:23:57 +0000 (UTC) Cc: Dmitry Antipov , emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 30 16:23:50 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XNjZD-0000EK-Qr for ged-emacs-devel@m.gmane.org; Sat, 30 Aug 2014 16:23:47 +0200 Original-Received: from localhost ([::1]:46696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNjZD-0008HK-B2 for ged-emacs-devel@m.gmane.org; Sat, 30 Aug 2014 10:23:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNjZ5-0008H7-E9 for emacs-devel@gnu.org; Sat, 30 Aug 2014 10:23:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNjZ0-0005kt-0x for emacs-devel@gnu.org; Sat, 30 Aug 2014 10:23:39 -0400 Original-Received: from hermes.netfonds.no ([80.91.224.195]:34489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNjYz-0005g1-Ql for emacs-devel@gnu.org; Sat, 30 Aug 2014 10:23:33 -0400 Original-Received: from 46.157.241.80.tmi.telenormobil.no ([46.157.241.80] helo=building.gnus.org) by hermes.netfonds.no with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1XNjYb-0006u6-Px; Sat, 30 Aug 2014 16:23:09 +0200 In-Reply-To: <5400EE70.8050207@cs.ucla.edu> (Paul Eggert's message of "Fri, 29 Aug 2014 14:19:44 -0700") User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux) X-MailScanner-ID: 1XNjYb-0006u6-Px MailScanner-NULL-Check: 1410013390.05033@Opd1MGEqQwt7YKTalkkEWQ X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.224.195 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:173906 Archived-At: Paul Eggert writes: > One infelicity I noticed in the recent change to 'sort' in the trunk > is that the new implementation calls its predicate twice for each > comparison. This is because the Lisp API says the comparison function > returns a boolean (nil or non-nil), whereas qsort_r wants the > comparison function to return a ternary value (-1, 0, or 1). If the > predicate is expensive, the new Fsort can be twice as slow as the old. > We could tune it but I don't see how to get it any faster than 1.5x > slower than before, assuming random input and an expensive comparison > function. Uhm. Why has somebody introduced a new sort that's slower than the old sort? As somebody who sorts a lot of things in Emacs, that sounds kinda ... bad. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog http://lars.ingebrigtsen.no/