On Fri, Apr 12, 2019 at 8:35 AM Serhiy Storchaka <storch...@gmail.com> wrote:
> 12.04.19 16:44, Inada Naoki пише: > > When creating many dicts with same keys, dict need to > > lookup internal hash table while inserting each keys. > > > > It is costful operation. If we can reuse existing keys of dict, > > we can skip this inserting cost. > > > > Additionally, we have "Key-Sharing Dictionary (PEP 412)". > > When all keys are string, many dict can share one key. > > It reduces memory consumption. > > It looks contrary to simplification made in Python 3 when we get rid of > some more efficient lists in favor of more general iterators. > > If this is a common case 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). This doesn't strike me as needing an optimization through a dedicated method. -Brett > we can add an invisible optimization for > dict(zip(keys, values)), especially if keys is a key-sharing dictionary. > This will benefit all users without the need to rewrite the code to use > the new special method. > > The interface of dict is already overloaded. It contains many methods > which most users use rarely (and therefore which are not kept in the > working set of memory). > > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > https://mail.python.org/mailman/options/python-dev/brett%40python.org >
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com