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: What's missing in ELisp that makes people want to use cl-lib? Date: Mon, 13 Nov 2023 00:09:02 +0200 Message-ID: <320999cc-6c83-2315-0044-cc0403400af3@gutov.dev> References: <12da6bcb-1818-7fbe-12af-8d4607724332@gutov.dev> <87il6bt4z0.fsf@yahoo.com> <8734xetjkk.fsf@yahoo.com> <87cywhsrcf.fsf@yahoo.com> <87cywgx1z0.fsf@web.de> <83wmuowwp3.fsf@gnu.org> <8334xcwank.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10981"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: =?UTF-8?Q?Gerd_M=c3=b6llmann?= , Eli Zaretskii , michael_heerdegen@web.de, emacs-devel@gnu.org To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 12 23:10:23 2023 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 1r2Ier-0002gb-VE for ged-emacs-devel@m.gmane-mx.org; Sun, 12 Nov 2023 23:10:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2Idy-0004BQ-39; Sun, 12 Nov 2023 17:09:26 -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 1r2Ido-0004Ae-Vt for emacs-devel@gnu.org; Sun, 12 Nov 2023 17:09:17 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r2Idj-0007UZ-NR; Sun, 12 Nov 2023 17:09:14 -0500 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BFDB15C00C0; Sun, 12 Nov 2023 17:09:05 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 12 Nov 2023 17:09:05 -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:sender:subject:subject:to:to; s=fm2; t= 1699826945; x=1699913345; bh=9to6kxKWtCcHDRyuC/+JR4i2V8Iocd6/md9 bPMqs7Q0=; b=kAgTUNKtjV8jmYb1vOXMrUNLEq5+iaPqWmPixrIWHhTOtccUalg 3i0mECrtL41JIUD9vPQlQctLF5JxeF4TF01W071/E+oQ3EyWecmvTIS/O+QcrCg3 nzIeNJVZUp8c0K1RmO+i1j/4HE/ioeAi+gr0N0RVjKQrc5MIOdnLiR6d4dQNpc3m g93uMVVOAtnAmZ1W0ayNWS04fChH7ZGW4n+RR3fTRJ1FxM5BsNNC+Ij3pv91EZOn uO1AqmoVQNmquFSfY/CceyiwJFzxNtuWTGfWKqQXSHml25ycawzC9gqq4bpIxM/z 0HB8auL29RdnN4rBJ/RMo2J9K3GOI+nrndg== 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:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1699826945; x=1699913345; bh=9to6kxKWtCcHDRyuC/+JR4i2V8Iocd6/md9 bPMqs7Q0=; b=kM4mTetlyMliZU0T75JRiOEbKjbbDhq3yZo29EPoioMwJn8H1gG P4b5g8vOsFe8d0GQkqgZl5NQWLTEoC+uTPC8cLigdb99ULljAryO5cFl+A9P94+S gf9HK7qqp94aHcQkmXyuiB+OUWUV7CLV0sOqhgQmPe16+BE3hKlEqKZfhHl9sj3d irbinQdvu3Ze2YqFAzfcImDE8vNgjoAGnPLHiZl92NBQxFSpMCS79XG1WqkIiUE1 0UY20nfjeUMq7y8dfOBhwJGaLI3sz4ULpwct+2qw3BLFC69XFJEV1zEAGvNzFuXZ BI0a5umz8rPDHvkFXozBECcOot6FkDvjpbw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddvkedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomhepffhm ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg htthgvrhhnpefhffehleejffegffeugefhkeektdffgfehjedvgeejtedtudehueffgffg feejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 12 Nov 2023 17:09:03 -0500 (EST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=66.111.4.28; envelope-from=dmitry@gutov.dev; helo=out4-smtp.messagingengine.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 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, NICE_REPLY_A=-2.553, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:312664 Archived-At: On 12/11/2023 04:36, João Távora wrote: >> cl-lib is not that well-optimized either. > That's certainly true. I've been looking at the code and there > are some serious optimization opportunities in cl-lib.el. The > one you found right away, destructive versions delegating to > overconsing non-destructive ones, but also other opportunities. > > I attach a patch that I hope you can try with that bug report. > Very lightly tested here, but seems to show a measurable > improvement. Looks like a solid improvement: (setq cc (all-completions "" obarray)) ;; (length cc) => 46002 (defvar list2 '("abc" "abc" "abc" "abc" "abc" "abc")) (benchmark-run 10 (cl-set-difference cc list2 :test 'equal)) ;; => 0.430 (benchmark-run 10 (setq cc (cl-nset-difference cc list2 :test 'equal))) ;; => 0.137 (!) (benchmark-run 10 (my/set-difference cc list2)) ;; => 0.144 (benchmark-run 10 (seq-difference cc list2)) ;; => 0.814 (defun my/set-difference (list1 list2) (delq 'wrong (mapcar (lambda (c) (if (member c list2) 'wrong c)) list1))) So it seems on par with the hand-written version (byte-compiled, too) that hardcodes the test function. Curiously, though, if I make list2 longer (e.g. 12 elements rather than 6), then my/set-difference starts to win noticeably (0.166 vs 0.200). I'll keep the real-world case as-is (code in project--vc-list-files) both because the result with cl-nset-difference is still a little slower, and because it's slower in all released emacsen, but it definitely becomes an option.