[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: performance of converting alist to hash table
From: |
Dai Yuwen |
Subject: |
Re: performance of converting alist to hash table |
Date: |
Sun, 16 May 2004 12:14:31 +0000 |
User-agent: |
Mutt/1.4.2.1i |
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 <address@hidden>
> >
> > 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
--
address@hidden
SDF Public Access UNIX System - http://sdf.lonestar.org
- performance of converting alist to hash table, Dai Yuwen, 2004/05/16
- Re: performance of converting alist to hash table, Ted Zlatanov, 2004/05/17
- Re: performance of converting alist to hash table, Miles Bader, 2004/05/17
- Re: performance of converting alist to hash table, Dai Yuwen, 2004/05/18
- Re: performance of converting alist to hash table, Stefan Monnier, 2004/05/18
- Re: performance of converting alist to hash table, Dai Yuwen, 2004/05/19
- Re: performance of converting alist to hash table, Kenichi Handa, 2004/05/19
- Re: performance of converting alist to hash table, Dai Yuwen, 2004/05/26