From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Dai Yuwen Newsgroups: gmane.emacs.devel Subject: Re: performance of converting alist to hash table Date: Sun, 16 May 2004 12:14:31 +0000 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040516121431.GA29093@SDF.LONESTAR.ORG> References: <20040516095522.GA1625@SDF.LONESTAR.ORG> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1084710633 27508 80.91.224.253 (16 May 2004 12:30:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 16 May 2004 12:30:33 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun May 16 14:30:24 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BPKme-0008Sb-00 for ; Sun, 16 May 2004 14:30:24 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BPKme-0001aY-00 for ; Sun, 16 May 2004 14:30:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BPKcu-0001oo-V1 for emacs-devel@quimby.gnus.org; Sun, 16 May 2004 08:20:21 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BPKcZ-0001mQ-AD for emacs-devel@gnu.org; Sun, 16 May 2004 08:19:59 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BPKc2-0001jF-L9 for emacs-devel@gnu.org; Sun, 16 May 2004 08:19:57 -0400 Original-Received: from [192.94.73.20] (helo=sdf.lonestar.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BPKXI-0001E0-W8 for emacs-devel@gnu.org; Sun, 16 May 2004 08:14:33 -0400 Original-Received: from sdf.lonestar.org (IDENT:daiyuwen@sdf.lonestar.org [192.94.73.1]) by sdf.lonestar.org (8.12.10/8.12.10) with ESMTP id i4GCEVvW010409 for ; Sun, 16 May 2004 12:14:31 GMT Original-Received: (from daiyuwen@localhost) by sdf.lonestar.org (8.12.10/8.12.8/Submit) id i4GCEVRx013608 for emacs-devel@gnu.org; Sun, 16 May 2004 12:14:31 GMT Original-To: emacs-devel@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:23526 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:23526 On Sun, May 16, 2004 at 01:18:07PM +0200, Eli Zaretskii wrote: > > Date: Sun, 16 May 2004 09:55:22 +0000 > > From: Dai Yuwen > > > > I'm trying to convert a large alist(nearly 7000 elements in it) to a > > hash table. But I found the performence of my function is poor: on a > > Celeron 333MHz, 196M memory system, it'll take 15 seconds to finish > > converting. > > > > This is the function: > > > > (defun convert-alist-to-hash (table w) > > (let ((l w)) > > (while l > > (setq char (car (car l)) > > key (car (cdr (car l))) > > l (cdr l)) > > (puthash char key table)))) > > Did you try `mapcar' and its variants? > I use `mapc' like this: (defun convert-alist-to-hash (table w) (mapc (lambda (e) (puthash (car e) (cadr e) table)) w)) Almost the same time needed. (I made a mistake in the previous email, it should be 30 seconds instead of 15.) best regards, Dai Yuwen -- daiyuwen@sdf.lonestar.org SDF Public Access UNIX System - http://sdf.lonestar.org