项目作者: phantie

项目描述 :
Dictionary restricted in growth, FIFO
高级语言: Python
项目地址: git://github.com/phantie/bound-sized-hash-map.git
创建时间: 2021-01-04T08:06:46Z
项目社区:https://github.com/phantie/bound-sized-hash-map

开源协议:MIT License

下载


bound-sized-hash-map

Dictionary restricted in growth, FIFO. Updating values via a key prolongs live of the key-value pair.

  1. (take(BoundSizedDict(2))(print)
  2. .__setitem__('a', 20)(print)
  3. .__setitem__('b', 30)(print)
  4. .__setitem__('a', 40)(print)
  5. .__setitem__('c', 50)(print)
  6. .__setitem__('d', 60)(print))

Output:

  1. {}
  2. {'a': 20}
  3. {'a': 20 'b': 30}
  4. {'b': 30 'a': 40}
  5. {'a': 40 'c': 50}
  6. {'c': 50 'd': 60}

Import:

  1. from bmap import BoundSizedDict

Install:

  1. pip install git+https://github.com/phantie/bound-sized-hash-map -U