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

2019年4月22日 16:08:41 -0700

On Tue, Apr 23, 2019 at 2:18 AM Chris Barker via Python-Dev
<[email protected]> wrote:
>
> On Fri, Apr 12, 2019 at 10:20 AM Brett Cannon <[email protected]> wrote:
>>>
>>>
>> This doesn't strike me as needing an optimization through a dedicated method.
>
> maybe a new dict mapping type -- "shared_dict" -- it would be used in places 
> like the csv reader where it makes sense, but wouldn't impact the regular 
> dict at all.
>
> you could get really clever an have it auto-convert to a regular dict when 
> any changes were made that are incompatible with the shared keys...
My current idea is adding builder in somewhere in stdlib (maybe collections?):
 builder = DictBuilder(keys_tuple)
 value = builder(values) # repeatedly called.
I don't want to add new mapping type because we already have shared key dict,
and changing mapping type may cause backward compatibility problem.
Regards,
-- 
Inada Naoki <[email protected]>
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to