<div class="gmail_extra"><div class="gmail_quote"><div>Chris Withers wrote: </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 14/11/2012 09:58, Merlijn van Deen wrote:<br>
> On 14 November 2012 10:12, Chris Withers <<a href="mailto:chris@simplistix.co.uk">chris@simplistix.co.uk</a>> wrote:<br>
>> ...which made me a little sad<br>
><br>
> Why did it make you sad? dict() takes 0.2?s, {} takes 0.04?s. In other<br>
> words: you can run dict() _five million_ times per second, and {}<br>
> twenty-five million times per second. That is 'a lot' and 'a lot'. It<br>
> also means you are unlikely to notice the difference in real-world<br>
> code. Just use the one you feel is clearer in the situation, and don't<br>
> worry about micro-optimalization.<br>
<br>
I'm inclined to agree, but it makes me sad for two reasons:<br>
<br>
- it's something that people get hung up on, for better or worse. (if it<br>
wasn't, Doug wouldn't have written his article)<br>
<br>
- it can make a difference, for example setting up a dict with many keys<br>
at the core of a type loop.<br>
<br>
Without looking at implementation, they should logically perform the same...<br>
<br></blockquote><div>Well, without looking at the implementation, you could form any opinion you</div><div>like about how they should perform. Still you could speculate that dict() will</div><div>require a builtins name lookup, and that the process of passing keyword arguments</div>
<div>might itself involve constructing a dictionary, so must inherently take at least</div><div>a little longer than compiling a {} literal.</div><div><br></div><div>Peter</div><div><br></div></div></div>