On Sat, 21 Jul 2007 16:20:37 -0700, genro wrote:

> On Jul 19, 6:29 am, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
>> No "surprise" here, but it can indeed be suboptimal if instanciating
>> myobject is costly.
> 
> What about this way ?
> 
> my_obj = my_dict.get(key) or my_dict.setdefault(key,myobject())

Reduces the unnecessary instantiation of `myobject` to "false" objects. 
May be not good enough.

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to