当前位置:网站首页>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边栏推荐
- Use of cocospods
- [OJ] intersection of two arrays (set, hash mapping...)
- Interface difference test - diffy tool
- Optimization of streaming media technology
- Top Devops tool chain inventory
- Several methods of the minimum value in the maximum value of group query
- [array] binary search
- RTP 接发ps流工具改进(二)
- 可知论与熟能生巧
- Interpretation of new plug-ins | how to enhance authentication capability with forward auth
猜你喜欢

Mapper agent development

JDBC tutorial

程序分析与优化 - 9 附录 XLA的缓冲区指派
![[shutter] shutter open source project reference](/img/3f/b1d4edd8f8e8fd8e6b39548448270d.jpg)
[shutter] shutter open source project reference

Wechat applet basic learning (wxss)

JSON data transfer parameters

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

Highly available cluster (HAC)

Many to one, one to many processing

监控容器运行时工具Falco
随机推荐
How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
What experience is there only one test in the company? Listen to what they say
Returns the size of the largest binary search subtree in a binary tree
What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
[live broadcast appointment] database obcp certification comprehensive upgrade open class
Flexible combination of applications is a false proposition that has existed for 40 years
Codeforces Round #771 (Div. 2)---A-D
Detailed explanation of 'viewpager' in compose | developer said · dtalk
直击产业落地!飞桨重磅推出业界首个模型选型工具
130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
[shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)
Realization of mask recognition based on OpenCV
JDBC练习案例
Dishes launcher small green program and directory management (efficiency tool)
JDBC教程
MySQL advanced learning notes (III)
Improvement of RTP receiving and sending PS stream tool (II)
Bean加载控制
Practical series - free commercial video material library
Master the development of facial expression recognition based on deep learning (based on paddlepaddle)