conditional computation

robert no-spam at no-spam-no-spam.com
Thu Oct 26 15:30:04 EDT 2006


I want to use a computation cache scheme like


	o = CACHECOMPUTE  complex-key-expr  expensive-calc-expr 


frequently and elegantly without writing complex-key-expr or expensive-calc-expr twice.
So its ugly:

	_=complex-key-expr; o=cache.get(_) or cache.setdefault(_,expensive-calc-expr)

Any ideas?

-robert




More information about the Python-list mailing list