Limiting the size of a python dictionary
Posted
by anthony
on Stack Overflow
See other posts from Stack Overflow
or by anthony
Published on 2010-03-13T07:19:49Z
Indexed on
2010/03/13
7:25 UTC
Read the original article
Hit count: 192
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. It would be nice if it was the least recently inserted/accesses key but that's not completely necessary.
If this exists in the standard library please save me some time and point it out!
© Stack Overflow or respective owner