in reply to Doubt about fly-weight objects.

You can avoid adding your own caching by using Memoize: use Memoize; memoize('new'); This wraps your constructor with a caching version. It may not be faster, but the resulting code is cleaner.

Replies are listed 'Best First'.
Re^2: Doubt about fly-weight objects.
by blazar (Canon) on May 17, 2005 at 16:50 UTC
    I do know about memoize. It must have been one of the very first modules I ever discovered - I seem to remember having read about it in an article. Generally I prefer to do memoizing by myself: don't know why and couldn't give any good reason - generally I'm not terribly concerned about efficiency, especially micro-optimization-wise.

    I must admit, however, that for some other reason I couldn't say, I had never thought of using it on (subs called like) methods.