[Python-Dev] Proposal: dict.with_values(iterable)

Inada Naoki songofacandy at gmail.com
Tue Apr 23 11:53:10 EDT 2019


On Wed, Apr 24, 2019 at 12:28 AM Steve Dower <steve.dower at python.org> wrote:
>
> >
> > But if the original dictionary wasn't created with shared keys... the
> > copy can't share them either.  Or are you suggesting adding new code to
> > create a shared key dictionary from one that isn't?
>
> This is a good point. Maybe dict.fromkeys() could do it? Or a
> sys.intern-like function (which is why I brought up that precedent). The
> point is to make it an optional benefit rather than strict
> language/library semantics.
>

Then, why not support values when creating key sharing dict?
That's one form of my proposal :)

-- 
Inada Naoki  <songofacandy at gmail.com>


More information about the Python-Dev mailing list