Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Re: Re: Favourite modules April 2003

by mirod (Canon)
on Apr 15, 2003 at 18:53 UTC ( #250645=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Favourite modules April 2003
in thread Favourite modules April 2003

The function I memoize gets passed a file name, slurps the file, normalizes spaces and computes its MD5. So I don't think the content of the file is cached, as it is internal to the function.

I agree that using Memoize only saves me the cost of a hash (filename => MD5). I just like how easy it is to use it, and how it removes some extra code. As programers we are used to adding extra data structures and code to cache that kind of result, but really, using Memoize gets us closer to the initial algorithm for solving the problem. At least that's how I justify using it here ;--)

  • Comment on Re: Re: Re: Favourite modules April 2003

Replies are listed 'Best First'.
Re: Re: Re: Re: Favourite modules April 2003
by cees (Curate) on Apr 16, 2003 at 04:27 UTC

    That makes more sense. Memoize will only cache the arguements to the function, and the return value so you are fine with your implementation. Sorry for jumping on this, but I thought that you might be doing something like the following:

    use Digest::MD5 qw(md5); use Memoize; memoize('md5');

    This would use gobs of memory (depending on the input) and wouldn't really accomplish anything useful.

    Do I get an award for coming up with the most unproductive use of Memoize???

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://250645]
[zentara]: Strange, on clicking a link in a node, I am taken to that node, but my votes and login are lost. Should I post a Permonks Discussion?
[choroba]: that just means someone used a wrong link format
[choroba]: msg them or consider to fix
[zentara]: Gratias

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-05-26 12:30 GMT
Find Nodes?
    Voting Booth?