Hi! On Wed, Dec 10, 2014 at 12:47:17AM +0100, "Fetchinson ." <fetchin...@googlemail.com> wrote: > 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
I hope you know that SQLObject converts _get_* and _set_* methods to properties so you shouldn't decorate the methods. Also most caching decorators are not thread-safe so you'd better implement your own caching with proper locking. Oleg. -- Oleg Broytman http://phdru.name/ p...@phdru.name Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------------ 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