What's the best strategy for some kind of caching of an expensive property?

Let's say I have the following:

class obj( SQLObject ):
    somefield = StringCol( )
    someotherfield = StringCol( )

    def _get_expensivestuff( self ):
        # takes a long time
        return result

And if my obj instance is alive for a long time and expensivestuff
gets accessed many times I'd like to just compute result once, store
it somewhere (where?) and return it from there.

I'm aware of memoizing the result of a function using a suitable
decorator but I'm concerned about thread safety and I'm not terribly
knowledgeable about the internals of sqlobject.

Any ideas would help a lot. Thanks,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to