Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Fast wordlist lookup for game

by jerrygarciuh (Curate)
on Oct 29, 2002 at 22:52 UTC ( [id://208905]=note: print w/replies, xml ) Need Help??


in reply to Re: Fast wordlist lookup for game
in thread Fast wordlist lookup for game

Thanks for the reply but I have to say that memory always seems to be an issue if one uses expensive methods and the script gets heavily used at all.
Thanks though,
jg

Replies are listed 'Best First'.
Re: Re: Re: Fast wordlist lookup for game
by sauoq (Abbot) on Oct 29, 2002 at 23:56 UTC

    Use a hash to minimize the search time. Keep the hash on disk to minimize the memory usage (and start-up time if this is a CGI app.) I.e. Use a DBM. For speed, you'll probably find BerkeleyDB is best.

    -j
    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Re: Re: Fast wordlist lookup for game
by agentv (Friar) on Oct 29, 2002 at 23:02 UTC
    ...oops, I guess I finished my post after you'd already seen a similar answer.

    You're right that it's expensive to keep the list in memory, but it will be the fastest, and we're not talking a lot of memory here (given a list with words on average the size of the words in the Unix dictionary).

    Reading things into the hash is not he most elegant solution, and someone will no doubt come along here in a moment with a suggestion for a module that does more closely what you desire, but I wouldn't discount the simplest approach, unless your program will have other memory intensive techniques that cannot be avoided.

    ...All the world looks like -well- all the world, when your hammer is Perl.
    ---v

      Thanks agentv,
      I will keep an open mind on this. I will be using this as the backend of a Flash game and since that will mean repeatedly incurring the memory penalty I doubt it will be the way I go. Guess it would have been much smarter of me to have said so in my original post, eh?
      Thanks for the replies!
      jg

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://208905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found