all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: persistent obarray?
Date: Mon, 26 Dec 2005 15:34:44 -0800	[thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICGEMODAAA.drew.adams@oracle.com> (raw)
In-Reply-To: <MEEKKIABFKKDFJMPIOEBKECICOAA.drew.adams@oracle.com>

    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))))

  reply	other threads:[~2005-12-26 23:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-26 22:36 persistent obarray? Drew Adams
2005-12-26 23:34 ` Drew Adams [this message]
     [not found] <mailman.20504.1135640183.20277.help-gnu-emacs@gnu.org>
2005-12-29  4:01 ` Stefan Monnier

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=DNEMKBNJBGPAOPIJOOICGEMODAAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /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.