当前位置:网站首页>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 10
It 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
ChainMap
cover?ChainMap
What use cases are covered ? - Are there any real world examples of
ChainMap
?ChainMap
Is 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边栏推荐
- JSON数据传递参数
- PHP get real IP
- PR FAQ, what about PR preview video card?
- A single element in an ordered array -- Valentine's Day mental problems
- Interface difference test - diffy tool
- Load balancing cluster (LBC)
- Is the multitasking loss in pytoch added up or backward separately?
- List of major chip Enterprises
- The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
- JDBC tutorial
猜你喜欢
JDBC tutorial
How to apply for company email when registering in company email format?
MySQL基础
Writing of head and bottom components of non routing components
Happy Lantern Festival, how many of these technical lantern riddles can you guess correctly?
基于OpenCV实现口罩识别
Interface switching based on pyqt5 toolbar button -2
Explain in detail the process of realizing Chinese text classification by CNN
Wechat applet basic learning (wxss)
Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
随机推荐
Matlab 信号处理【问答笔记-1】
Create an interactive experience of popular games, and learn about the real-time voice of paileyun unity
Codeforces Round #771 (Div. 2)---A-D
Interface switching based on pyqt5 toolbar button -2
程序分析与优化 - 9 附录 XLA的缓冲区指派
RTP 接发ps流工具改进(二)
Yolox enhanced feature extraction network panet analysis
Master the development of facial expression recognition based on deep learning (based on paddlepaddle)
QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)
yolov5train. py
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
Mapper代理开发
接口差异测试——Diffy工具
Practical series - free commercial video material library
S12. Verify multi host SSH mutual access script based on key
Wechat applet basic learning (wxss)
Returns the maximum distance between two nodes of a binary tree
接口自动化覆盖率统计——Jacoco使用
VIM interval deletion note
Custom throttling function six steps to deal with complex requirements