[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: pseudo self modifying code?
- From: Ross Berteig <Ross@...>
- Date: Thu, 03 Feb 2011 15:42:45 -0800
Sometime on 2/1/2011, Patrick Mcavery wrote:
>Rather then using a DB or tables & Pluto I was thinking about
>storing information in Lua scripts that would then be executed by
>other Lua scripts via dofile. I was thinking that the executing
>script could also modify the storage script for persistence. This
>set up would also allow me to hand edit the storage script later,
>bypassing the main limitation I see with a DB or a serialization
>library like Pluto.
As an anecdotal data point, I recently needed to shuffle the text
of a dictionary. The data was about 100K+ words with definitions,
in 28 MB. I wrote a short Lua script that transformed the flat
text file into a Lua module containing a table in the form of an
array of tables with one table per word containing the word
itself and a string holding its full definition. Serialized to a
file, that is a single Lua source file containing a single Lua
table totally about 32MB of source text.
The resulting module loads into small scripts with require"words"
in a matter of a few seconds on a four year old PC.
I'd say that the result of dead simple serialization (I used
string.format and its %q directive for the strings) is a file
that loads faster than parsing the original text, and is still
Ross Berteig Ross@CheshireEng.com
Cheshire Engineering Corp. http://www.CheshireEng.com/