From: Dai Yuwen <daiyuwen@sdf.lonestar.org>
Subject: Re: performance of converting alist to hash table
Date: Sun, 16 May 2004 12:14:31 +0000 [thread overview]
Message-ID: <20040516121431.GA29093@SDF.LONESTAR.ORG> (raw)
In-Reply-To: <uy8nsy61c.fsf@gnu.org>
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 <daiyuwen@sdf.lonestar.org>
> >
> > 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
next prev parent reply other threads:[~2004-05-16 12:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-16 9:55 performance of converting alist to hash table Dai Yuwen
2004-05-16 10:13 ` Thien-Thi Nguyen
2004-05-16 12:35 ` Dai Yuwen
2004-05-16 11:18 ` Eli Zaretskii
2004-05-16 12:14 ` Dai Yuwen [this message]
2004-05-16 14:02 ` Andreas Schwab
2004-05-16 15:51 ` Adrian Aichner
2004-05-17 1:18 ` Dai Yuwen
2004-05-17 17:43 ` Ted Zlatanov
2004-05-17 23:37 ` Miles Bader
2004-05-18 11:50 ` Dai Yuwen
2004-05-18 13:42 ` Stefan Monnier
2004-05-19 11:59 ` Dai Yuwen
2004-05-19 23:27 ` Kenichi Handa
2004-05-26 13:29 ` Dai Yuwen
2004-05-26 23:21 ` Kenichi Handa
2004-05-18 12:23 ` David Kastrup
2004-05-19 12:02 ` Dai Yuwen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040516121431.GA29093@SDF.LONESTAR.ORG \
--to=daiyuwen@sdf.lonestar.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.