当前位置:网站首页>collections. What is the purpose of chainmap- What is the purpose of collections. ChainMap?
collections. What is the purpose of chainmap- What is the purpose of collections. ChainMap?
2022-07-03 00:04:00 【Technology feast】
problem :
In Python 3.3 a ChainMap class was added to the collections module: stay Python 3.3 in , One ChainMap Class is added to collections Module :
A ChainMap class is provided for quickly linking a number of mappings so they can be treated as a single unit. Provides a ChainMap class , Used to quickly link multiple mappings , In order to treat them as a unit .It is often much faster than creating a new dictionary and running multiple update() calls. It is usually more than creating a new dictionary and running multiple update() Call much faster .
Example: example :
>>> from collections import ChainMap>>> x = {'a': 1, 'b': 2}>>> y = {'b': 10, 'c': 11}>>> z = ChainMap(y, x)>>> for k, v in z.items(): print(k, v)a 1c 11b 10It was motivated by this issue and made public by this one (no PEP was created). It is motivated This problem , And through public This one ( No PEP establish ).
As far as I understand, it is an alternative to having an extra dictionary and maintaining it with update() s. as far as I am concerned , It's an alternative , There is an extra dictionary , And use update() s Maintain it .
The questions are: The problem is :
- What use cases does
ChainMapcover?ChainMapWhat use cases are covered ? - Are there any real world examples of
ChainMap?ChainMapIs there any real-world example ? - Is it used in third-party libraries that switched to python3? Is it used to switch to python3 Third party library ?
Bonus question: is there a way to use it on Python2.x? Additional questions : Is there any way Python2.x Use it on ?
I've heard about it in Transforming Code into Beautiful, Idiomatic Python PyCon talk by Raymond Hettinger and I'd like to add it to my toolkit, but I lack in understanding when should I use it. I am here Raymond Hettinger Of “ Transforming Code into Beautiful, Idiomatic Python PyCon Transforming Code into Beautiful, Idiomatic Python Heard of it , I want to add it to my toolkit , But I don't know when to use it .
Solution :
Reference resources : https://stackoom.com/en/question/1a9a4边栏推荐
- Interface automation coverage statistics - used by Jacobo
- sourcetree 详细
- Codeforces Round #771 (Div. 2)---A-D
- [Verilog tutorial]
- Interpretation of new plug-ins | how to enhance authentication capability with forward auth
- Additional: token; (don't read until you finish writing...)
- [live broadcast appointment] database obcp certification comprehensive upgrade open class
- Intranet penetration | teach you how to conduct intranet penetration hand in hand
- VIM interval deletion note
- MySQL advanced learning notes (III)
猜你喜欢

How much do you know about synchronized?

PR FAQ, what about PR preview video card?

Detailed explanation of 'viewpager' in compose | developer said · dtalk

In February 2022, the ranking list of domestic databases: oceanbase regained its popularity with "three consecutive increases", and gaussdb is expected to achieve the largest increase this month

Improvement of RTP receiving and sending PS stream tool (II)

How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
![[analysis of STL source code] imitation function (to be supplemented)](/img/40/a02a04a24f385a31e0484d1071ecec.jpg)
[analysis of STL source code] imitation function (to be supplemented)

Pytorch里面多任务Loss是加起来还是分别backward?

QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)

Writing of head and bottom components of non routing components
随机推荐
開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
流媒体技术优化
In February 2022, the ranking list of domestic databases: oceanbase regained its popularity with "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
直击产业落地!飞桨重磅推出业界首个模型选型工具
VIM interval deletion note
How to apply for company email when registering in company email format?
@How to use bindsinstance in dagger2
附加:token;(没写完,别看…)
sourcetree 详细
2022 latest and complete interview questions for software testing
Top Devops tool chain inventory
JVM foundation review
JSON data transfer parameters
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)
[live broadcast appointment] database obcp certification comprehensive upgrade open class
开源了 | 文心大模型ERNIE-Tiny轻量化技术,又准又快,效果全开
Yolox enhanced feature extraction network panet analysis
判断二叉树是否为满二叉树