使用自适应替换缓存的备忘录装饰器。
arc_cache的Python项目详细描述
自适应替换缓存-python3装饰器
主要是为了自学。使用风险自负。
用法
fromarc_cacheimportarc_cache@arc_cache()defmy_heavy_function(arg1):do_stuff()
开发
使用设置virtualenv
$ pip3 install tox $ tox -e develop $ . .venv/bin/activate
测试
使用
运行所有测试$ tox
释放
$ python setup.py bdist sdist bdist_wheel $ gpg -u ... --detach-sign -a dist/... $ twine upload dist/*
参考文献
python 3.5(我相信)使用了lru缓存的c实现。
- ARC-自调整、低开销替换缓存(2003)
- Adaptive Replacement Cache在维基百科上
- lru_cache在cpython 3.4中