From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Florian Beck Newsgroups: gmane.emacs.help Subject: Re: Problem with position and find (cl) Date: Sat, 21 Jun 2008 00:31:14 -0400 Organization: T-Online Message-ID: <87ve039zot.fsf@sophokles.streitblatt.de> References: <6c2bb4F3dibi5U1@mid.individual.net> <6c2gf4F3eltftU1@mid.individual.net> <87hcbng8z6.fsf@sophokles.streitblatt.de> <87abhfg0mn.fsf@sophokles.streitblatt.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1214023399 17869 80.91.229.12 (21 Jun 2008 04:43:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Jun 2008 04:43:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 21 06:44:03 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K9uxD-0006f7-Vy for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Jun 2008 06:44:00 +0200 Original-Received: from localhost ([127.0.0.1]:45616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K9uwP-0002vK-1L for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Jun 2008 00:43:09 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!goblin1!goblin.stu.neva.ru!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 55 Original-X-Trace: news.t-online.com 1214022675 02 27330 bj7kOr-rMTjsStAn 080621 04:31:15 Original-X-Complaints-To: usenet-abuse@t-online.de X-ID: Ze-cyEZfYeuB5f87YAhDnPuTYpIe0yuE8GZbHuLoqt3Fzaae7gvNUt User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:9E8QT7gNN6o0T/AWaC7T1p6GZ30= Original-Xref: news.stanford.edu gnu.emacs.help:159659 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:55013 Archived-At: Barry Margolin writes: > In article <87abhfg0mn.fsf@sophokles.streitblatt.de>, > Florian Beck wrote: > >> Thierry Volpiatto writes: >> >> >> > position default test is 'eq, try 'equal >> >> Indeed, many cl-tests default to 'eq. >> >> BTW, what is the reason for this (apart from being a language convention)? > > Just because things look similar doesn't mean they're the same. Imagine > if you use a list like (firstname lastname) to represent people, and you > have two John Smiths in the group. Yes, that was what I was trying to explain. >> >> When I try >> >> (let ((start-time (current-time))) >> (dotimes (i 1000000) >> (position '(1) '((2) (5) (2) 2 x 4 fer fer f r e wqf (1) fr r) :test >> 'eq)) >> (format-time-string "%S" (time-since start-time))) >> >> with 'eq and 'equal I get the same result. So 'eq is not more efficent, >> is it? > > For a single-element list the difference is almost negligible. Try > again with long lists, like 50 or 100 elements long. I doesn't scale, but not that quickly: (let ((start-time (current-time)) (test-list (append (make-list 10000 'x) '((1))))) (dotimes (i 1000) (position '(1) test-list :test 'equal)) (format"%.3f" (- (time-to-seconds (current-time)) (time-to-seconds start-time) ))) (let ((start-time (current-time)) (test-list (append (make-list 10000 'x) '((1))))) (dotimes (i 1000) (position '(1) test-list :test 'eq)) (format "%.3f" (- (time-to-seconds (current-time)) (time-to-seconds start-time) ))) This still takes more or less the same amount of time. (In my case 7.782s and 7.689s.) -- Florian Beck