I've been surprised by how much memory the data takes up, given how small it is when written to disk.
I use twin hashes, storing practically the same data, but in a different order. The script learns a sentence in two directions (front to back, back to front) so it can generate a sentence in either direction from a given keyword.
Right now each hash, on disk, takes up 727k (1.4M "brain") - but when loaded into the hash, takes up a remarkable 16M! (I've loaded the software without data to verify).
My hash is put together like so:
For comparison, I write every entry to disk in the format:$VAR1 = { 'Word1_Word2' => { 'Sym1' => 3, 'Sym2' => 1 }, 'Word3_Word4' => { 'Sym4' => 3, 'Sym3' => 1 }, 'Word5_Word6' => { 'Sym5' => 1 } };
Can you fine gentlemonks suggest a better way of storing data in memory, while also being easy to reference?Word1 \a Word2 \00 Sym1 \00 3 \n
JP,
-- Alexander Widdlemouse undid his bellybutton and his bum dropped off --
In reply to A more memory efficient storage structure? by JPaul
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |