当前位置:网站首页>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边栏推荐
- Tensorflow to pytorch notes; tf. gather_ Nd (x, y) to pytorch
- Classes and objects - initialization and cleanup of objects - constructor call rules
- 超好用的日志库 logzero
- I2C subsystem (IV): I2C debug
- 迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常
- Cron表达式介绍
- The solution of "the required function is not supported" in win10 remote desktop connection is to modify the Registry [easy to understand]
- 【翻译】具有集中控制平面的现代应用负载平衡
- 怎么将yolov5中的PANet层改为BiFPN
- Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid
猜你喜欢
I2C 子系统(四):I2C debug
Check log4j problems using stain analysis
HTB-Devel
[translation] modern application load balancing with centralized control plane
Sous - système I2C (IV): débogage I2C
Kubernetes cluster log and efk architecture log scheme
Kubernetes cluster log and efk architecture log scheme
Add automatic model generation function to hade
SqlServer行转列PIVOT
[shutter] setup of shutter development environment (supplement the latest information | the latest installation tutorial on August 25, 2021)
随机推荐
[fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
SqlServer行转列PIVOT
Tensorflow to pytorch notes; tf. gather_ Nd (x, y) to pytorch
Kubernetes family container housekeeper pod online Q & A?
From C to capable -- use the pointer as a function parameter to find out whether the string is a palindrome character
【翻译】Flux安全。通过模糊处理获得更多信心
Serious security vulnerabilities reported by moxa mxview network management software
JMeter performance test JDBC request (query database to obtain database data) use "suggestions collection"
Global and Chinese ammonium dimolybdate market in-depth analysis and prospect risk prediction report 2022 Edition
Add MDF database file to SQL Server database, and the error is reported
vfork执行时出现Segmentation fault
[C language] MD5 encryption for account password
Linear rectification function relu and its variants in deep learning activation function
Add automatic model generation function to hade
Gbase 8C trigger (III)
Segmentation fault occurs during VFORK execution
The left value and the right finger explain better
yii2 中andWhere多个or查询 orm条件
用docker 连接mysql的过程
"Analysis of 43 cases of MATLAB neural network": Chapter 43 efficient programming skills of neural network -- Discussion Based on the characteristics of the new version of MATLAB r2012b