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: performance of converting alist to hash table Date: Sun, 16 May 2004 09:55:22 +0000 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <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 1084701880 14029 80.91.224.253 (16 May 2004 10:04:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 16 May 2004 10:04:40 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun May 16 12:04:32 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 1BPIVU-0004Zu-00 for ; Sun, 16 May 2004 12:04:32 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BPIVU-00068S-00 for ; Sun, 16 May 2004 12:04:32 +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 1BPIQh-0002Ki-SG for emacs-devel@quimby.gnus.org; Sun, 16 May 2004 05:59:35 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BPIQa-0002Jo-1w for emacs-devel@gnu.org; Sun, 16 May 2004 05:59:28 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BPIMp-0001Dd-6Q for emacs-devel@gnu.org; Sun, 16 May 2004 05:56:07 -0400 Original-Received: from [192.94.73.20] (helo=sdf.lonestar.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BPIMg-0000s3-FU for emacs-devel@gnu.org; Sun, 16 May 2004 05:55:27 -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 i4G9tMqY004197 for ; Sun, 16 May 2004 09:55:23 GMT Original-Received: (from daiyuwen@localhost) by sdf.lonestar.org (8.12.10/8.12.8/Submit) id i4G9tMfJ003976 for emacs-devel@gnu.org; Sun, 16 May 2004 09:55:22 GMT Original-To: emacs-devel@gnu.org Content-Disposition: inline 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:23523 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:23523 Dear all, 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)))) And how I call the function: (convert-alist-to-hash ta '(("w1" "aaaa") ("w2" "aa") ("w3" "aak") ...)) I once tried to write the above function as a macro since the alist is known at compiling time so that most work will be done at compiling time instead of runing time, but failed. Any idea? Thanks in advance. Best regards, Dai Yuwen -- daiyuwen@sdf.lonestar.org SDF Public Access UNIX System - http://sdf.lonestar.org