[Python-ideas] Idea: Lazy ... statement

Jim Jewett jimjjewett at gmail.com
Thu Oct 16 01:41:56 CEST 2008

On Wed, Oct 15, 2008 at 5:25 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Jim Jewett wrote:

>> Part of the problem with setdefault is that calculating the default
>> can be expensive.

> There's already a superior replacement for setdefault,
> i.e. use a defaultdict.

Only if the default can be calculated by the dict itself.  If some
information from the calling site is needed, there still isn't a good
answer.  That is a rare case, but does overlap with the cases where
calculation actually is expensive.


More information about the Python-ideas mailing list