<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 12, 2019 at 8:35 AM Serhiy Storchaka <<a href="mailto:storchaka@gmail.com">storchaka@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">12.04.19 16:44, Inada Naoki пише:<br>
> When creating many dicts with same keys, dict need to<br>
> lookup internal hash table while inserting each keys.<br>
> <br>
> It is costful operation.  If we can reuse existing keys of dict,<br>
> we can skip this inserting cost.<br>
> <br>
> Additionally, we have "Key-Sharing Dictionary (PEP 412)".<br>
> When all keys are string, many dict can share one key.<br>
> It reduces memory consumption.<br>
<br>
It looks contrary to simplification made in Python 3 when we get rid of <br>
some more efficient lists in favor of more general iterators.<br>
<br>
If this is a common case</blockquote><div><br></div><div>I think that "if" is my big sticking point. I don't think I've ever had a need for this and the zip() solution was what I originally thought of when I realized what the method was meant to do (which wasn't obvious to me initially).</div><div><br></div><div>This doesn't strike me as needing an optimization through a dedicated method.</div><div><br></div><div>-Brett<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> we can add an invisible optimization for <br>
dict(zip(keys, values)), especially if keys is a key-sharing dictionary. <br>
This will benefit all users without the need to rewrite the code to use <br>
the new special method.<br>
<br>
The interface of dict is already overloaded. It contains many methods <br>
which most users use rarely (and therefore which are not kept in the <br>
working set of memory).<br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/brett%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br>
</blockquote></div></div>