<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Nov 2, 2018 at 5:25 PM Anders Hovmöller <<a href="mailto:boxed@killingar.net">boxed@killingar.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Could you explain what the difference is between defaultdicts "factory which is unconditionally called when the key is missing" and "the default is evaluated only on need"?<br></blockquote><div><br></div><div>The distinction was the motivation for this thread: setdefault requires a constructed default instance as an argument, regardless of whether the key is missing, whereas defaultdict's factory is only called if necessary. If the key is present in a defaultdict, no default is constructed.</div></div></div>