[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LISP Questions - random, random elements and memory management

From: Kevin Rodgers
Subject: Re: LISP Questions - random, random elements and memory management
Date: Wed, 18 Nov 2009 20:03:51 -0700
User-agent: Thunderbird (Macintosh/20090812)

Jeff Clough wrote:
Lastly, I have a function that takes two lists, pulls a random element
from each and concats the elements to form a string (a random name
generator).  It works just swell with the lists as defconsts, but one
of the lists is quite large (88,000 elements today) and burns about a
megabyte of RAM.  It takes above half a second to evaluate the
defconst, but then using the list is zippy (even nth'ing near the end
of the list takes no time).

What is the done thing in Emacs Lisp to keep this data out of memory
until it's needed that also lets the function stay zippy?  Bonus
points if I can keep the data and function bundled up in the same .el

The data *is* in memory.  The function is zippy because nth is fast, in
turn because cdr is fast (and implemented in C).  And perhaps the cons
cells for the list are allocated in adjacent memory, if it is
constructed all at once.

Of course you can put the data (defconst forms) and function (defun) in
the same .el file!

I've taken a look at autoload, provide and require, but I'm not
certain I understand them fully or how they would be used to solve
this problem.

Me neither.

Kevin Rodgers
Denver, Colorado, USA

reply via email to

[Prev in Thread] Current Thread [Next in Thread]