* persistent obarray?
@ 2005-12-26 22:36 Drew Adams
2005-12-26 23:34 ` Drew Adams
0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2005-12-26 22:36 UTC (permalink / raw)
I have a large obarray (length 102701). To create it, I walk through a
(large) file of words, with many duplicates, interning each word traversed.
This takes 2-3 minutes. Currently, I create the obarrary when a given major
mode is entered for the first time.
I'm wondering if it would speed things up to write the completed obarray to
a Lisp file, and then read that file instead of creating the obarray as I do
now.
What are my options for doing that (to see if it is faster)? If I just write
the obarray, it will be read in as an ordinary vector, and, IIUC, that is
not a way to create an obarry (you must use intern). I could convert it to a
list, write that out, read it back in, and map intern over the list after
reading it. Is there another option?
Does it sound like this (write + read) would be worth trying? If so, is
there anything to be gained by byte-compiling the Lisp file? It would
contain only a list (or a setq or defvar with the list as value).
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: persistent obarray?
2005-12-26 22:36 persistent obarray? Drew Adams
@ 2005-12-26 23:34 ` Drew Adams
0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2005-12-26 23:34 UTC (permalink / raw)
I have a large obarray (length 102701). To create it, I walk
through a (large) file of words, with many duplicates, interning
each word traversed. This takes 2-3 minutes. Currently, I create
the obarrary when a given major mode is entered for the first time.
I'm wondering if it would speed things up to write the
completed obarray to a Lisp file, and then read that file
instead of creating the obarray as I do now.
What are my options for doing that (to see if it is faster)?
If I just write the obarray, it will be read in as an
ordinary vector, and, IIUC, that is not a way to create an
obarry (you must use intern). I could convert it to a
list, write that out, read it back in, and map intern over the
list after reading it. Is there another option?
Does it sound like this (write + read) would be worth trying?
If so, is there anything to be gained by byte-compiling the
Lisp file? It would contain only a list (or a setq or defvar
with the list as value).
Well, I tried it (haven't tried byte-compiling yet). It's a _zillion_ times
faster. Unless someone sees a better way, this is what I'm doing now:
Write:
(with-temp-file "foo"
(mapatoms (lambda (s) (push s my-list)) my-obarray)
(pp my-list (current-buffer)))
Read:
(if (not (file-readable-p "foo"))
(make-my-obarray) ; Create obarray from scratch
(let ((buf (find-file-noselect "foo" 'nowarn 'raw))
(obarray my-obarray))
(unwind-protect
(setq my-list (read buf))
(kill-buffer buf))))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: persistent obarray?
[not found] <mailman.20504.1135640183.20277.help-gnu-emacs@gnu.org>
@ 2005-12-29 4:01 ` Stefan Monnier
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2005-12-29 4:01 UTC (permalink / raw)
> (let ((obarray my-obarray))
> (unwind-protect
> (setq my-list (read buf))
> (kill-buffer buf))))
The let-binding of obarray is the main trick, yes.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-12-29 4:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-26 22:36 persistent obarray? Drew Adams
2005-12-26 23:34 ` Drew Adams
[not found] <mailman.20504.1135640183.20277.help-gnu-emacs@gnu.org>
2005-12-29 4:01 ` Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).