当前位置:网站首页>How to limit the size of the dictionary- How to limit the size of a dictionary?
How to limit the size of the dictionary- How to limit the size of a dictionary?
2022-07-03 02:51:00 【javail】
problem :
I'd like to work with a dict in python, but limit the number of key/value pairs to X. In other words, if the dict is currently storing X key/value pairs and I perform an insertion, I would like one of the existing pairs to be dropped. I want to python Use in dict, But will key / The number of value pairs is limited to X. let me put it another way , If dict Currently storing X Key / Value pair and I execute insert , I want one of the existing pairs to delete .It would be nice if it was the least recently inserted/accesses key but that's not completely necessary. If it is the least recently inserted / Just access the key , But this is not absolutely necessary .
If this exists in the standard library please save me some time and point it out! If this exists in the standard library , Please save me some time and point it out !
Solution :
Reference resources : https://stackoom.com/en/question/AE8P边栏推荐
- 《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨
- Random shuffle note
- Three.js本地环境搭建
- 定了,就选它
- Le processus de connexion mysql avec docker
- [fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
- Chart. JS multitooltip tag - chart js multiTooltip labels
- tensorflow转pytorch笔记;tf.gather_nd(x,y)转pytorch
- Source code analysis | layout file loading process
- I2C 子系统(二):I3C spec
猜你喜欢
Sous - système I2C (IV): débogage I2C
Mathematical statistics -- Sampling and sampling distribution
Three.js本地环境搭建
Joking about Domain Driven Design (III) -- Dilemma
Classes and objects - initialization and cleanup of objects - constructor call rules
Baidu map - surrounding search
I2C 子系统(二):I3C spec
I2C subsystem (IV): I2C debug
Can netstat still play like this?
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
随机推荐
用docker 連接mysql的過程
SqlServer行转列PIVOT
I2C 子系统(二):I3C spec
当lambda没有输入时,是何含义?
Kubernetes family container housekeeper pod online Q & A?
【翻译】后台项目加入了CNCF孵化器
左值右指解释的比较好的
Add automatic model generation function to hade
Gbase 8C system table PG_ amproc
【翻译】具有集中控制平面的现代应用负载平衡
Gbase 8C trigger (I)
The Linux server needs to install the agent software EPS (agent) database
SQL statement
Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid
From C to capable -- use the pointer as a function parameter to find out whether the string is a palindrome character
Gbase 8C function / stored procedure parameters (II)
2022-2028 global splicing display industry research and trend analysis report
Joking about Domain Driven Design (III) -- Dilemma
左连接,内连接
Random shuffle note