From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: remove-duplicates performances Date: Fri, 20 May 2011 11:09:55 -0300 Message-ID: References: <877h9lv5tl.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1305900613 2221 80.91.229.12 (20 May 2011 14:10:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 20 May 2011 14:10:13 +0000 (UTC) Cc: emacs-devel@gnu.org To: Thierry Volpiatto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 20 16:10:09 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QNQOx-0001Y4-Ub for ged-emacs-devel@m.gmane.org; Fri, 20 May 2011 16:10:04 +0200 Original-Received: from localhost ([::1]:41748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNQOw-0001cU-Eh for ged-emacs-devel@m.gmane.org; Fri, 20 May 2011 10:10:02 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:56782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNQOu-0001cC-Bv for emacs-devel@gnu.org; Fri, 20 May 2011 10:10:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNQOt-00033D-Eo for emacs-devel@gnu.org; Fri, 20 May 2011 10:10:00 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]:36352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNQOt-000337-DC for emacs-devel@gnu.org; Fri, 20 May 2011 10:09:59 -0400 Original-Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:33563 helo=ceviche.home) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QNQOs-0007fo-Rh; Fri, 20 May 2011 10:09:59 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 67AE96610B; Fri, 20 May 2011 11:09:55 -0300 (ART) In-Reply-To: <877h9lv5tl.fsf@gmail.com> (Thierry Volpiatto's message of "Fri, 20 May 2011 15:51:02 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.10 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:139548 Archived-At: > i just noticed that `remove-duplicates' is very slow. It's using an O(N=B2) algorithm, so it's indeed slow for long lists. > (setq A (let ((seq (loop for i from 1 to 10000 collect i))) > (append seq seq))) > (1 2 3 4 5 6 7 8 9 10 1 2 ...) For such long lists, I fully expect it to be slow. But for short lists, the overhead of constructing a hash-table should make the current code competitive. Can you try and find out for which lengths your code is better than the one we have? Stefan