{ "info": { "author": "Amit Dev", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Operating System :: POSIX", "Programming Language :: C", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "LRU Dict\n========\n\nA fixed size dict like container which evicts Least Recently Used (LRU) items\nonce size limit is exceeded. There are many python implementations available\nwhich does similar things. This is a fast and efficient C implementation.\nLRU maximum capacity can be modified at run-time.\nIf you are looking for pure python version, look `else where `_.\n\nUsage\n=====\n\nThis can be used to build a LRU cache. Usage is almost like a dict.\n\n.. code:: python\n\n from lru import LRU\n l = LRU(5) # Create an LRU container that can hold 5 items\n\n print l.peek_first_item(), l.peek_last_item() #return the MRU key and LRU key\n # Would print None None\n\n for i in range(5):\n l[i] = str(i)\n print l.items() # Prints items in MRU order\n # Would print [(4, '4'), (3, '3'), (2, '2'), (1, '1'), (0, '0')]\n\n print l.peek_first_item(), l.peek_last_item() #return the MRU key and LRU key\n # Would print (4, '4') (0, '0')\n\n l[5] = '5' # Inserting one more item should evict the old item\n print l.items()\n # Would print [(5, '5'), (4, '4'), (3, '3'), (2, '2'), (1, '1')]\n\n l[3] # Accessing an item would make it MRU\n print l.items()\n # Would print [(3, '3'), (5, '5'), (4, '4'), (2, '2'), (1, '1')]\n # Now 3 is in front\n\n l.keys() # Can get keys alone in MRU order\n # Would print [3, 5, 4, 2, 1]\n\n del l[4] # Delete an item\n print l.items()\n # Would print [(3, '3'), (5, '5'), (2, '2'), (1, '1')]\n\n print l.get_size()\n # Would print 5\n\n l.set_size(3)\n print l.items()\n # Would print [(3, '3'), (5, '5'), (2, '2')]\n print l.get_size()\n # Would print 3\n print l.has_key(5)\n # Would print True\n print 2 in l\n # Would print True\n\n l.get_stats()\n # Would print (1, 0)\n\n\n l.update(5='0') # Update an item\n print l.items()\n # Would print [(5, '0'), (3, '3'), (2, '2')]\n\n l.clear()\n print l.items()\n # Would print []\n\n def evicted(key, value):\n print \"removing: %s, %s\" % (key, value)\n\n l = LRU(1, callback=evicted)\n\n l[1] = '1'\n l[2] = '2'\n # callback would print removing: 1, 1\n\n l[2] = '3'\n # doesn't call the evicted callback\n\n print l.items()\n # would print [(2, '3')]\n \n del l[2]\n # doesn't call the evicted callback\n\n print l.items()\n # would print []\n\nInstall\n=======\n\n::\n\n pip install lru-dict\n\nor\n\n::\n\n easy_install lru_dict\n\n\nWhen to use this\n================\n\nLike mentioned above there are many python implementations of an LRU. Use this\nif you need a faster and memory efficient alternative. It is implemented with a\ndict and associated linked list to keep track of LRU order. See code for a more\ndetailed explanation. To see an indicative comparison with a pure python module,\nconsider a `benchmark `_ against\n`pylru `_ (just chosen at random, it should\nbe similar with other python implementations as well).\n\n::\n\n $ python bench.py pylru.lrucache\n Time : 3.31 s, Memory : 453672 Kb\n $ python bench.py lru.LRU\n Time : 0.23 s, Memory : 124328 Kb", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/amitdev/lru-dict", "keywords": "lru,dict", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "lru-dict", "package_url": "https://pypi.org/project/lru-dict/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/lru-dict/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/amitdev/lru-dict" }, "release_url": "https://pypi.org/project/lru-dict/1.1.6/", "requires_dist": null, "requires_python": null, "summary": "An Dict like LRU container.", "version": "1.1.6" }, "last_serial": 2510130, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "d69838c98a375e779436e6d641edee3e", "sha256": "d5c27815c121d2e3951c1d9c7f3e00797fbfa270950b240b8e453f43747750cb" }, "downloads": -1, "filename": "lru-dict-1.0.tar.gz", "has_sig": false, "md5_digest": "d69838c98a375e779436e6d641edee3e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5085, "upload_time": "2013-06-12T14:15:41", "url": "https://files.pythonhosted.org/packages/10/8e/7fdc5705036a5b010945ce10814187c51254bd6a24e51bbcd5f1a2109e4b/lru-dict-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "993cc4463040b1330a1edcbf99118cbc", "sha256": "f2b8104cbf6beb2c65a4329c257544ba093a1fb31b66cfab671f6ae23ce34f80" }, "downloads": -1, "filename": "lru-dict-1.1.tar.gz", "has_sig": false, "md5_digest": "993cc4463040b1330a1edcbf99118cbc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6781, "upload_time": "2014-10-14T15:26:15", "url": "https://files.pythonhosted.org/packages/94/d3/79fd241d04d3aac3e4445fc2bca3a935751c031fa53d866ed6c3f2245417/lru-dict-1.1.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "df83e13282f794efd35f59d06b718eda", "sha256": "6b96bdd5715eb1b9bf4aebe49b50fd9b70353d4035e67163c6ec35e9fa81b268" }, "downloads": -1, "filename": "lru-dict-1.1.1.tar.gz", "has_sig": false, "md5_digest": "df83e13282f794efd35f59d06b718eda", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8086, "upload_time": "2014-11-10T14:32:07", "url": "https://files.pythonhosted.org/packages/1d/2d/186a33b389fd1ae23c493a79eab568ea1bbf53a87d2ffa9d8c2602df552e/lru-dict-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "aaae00648873610f56634af123f475bb", "sha256": "5ca2d2e2b82d360d219e0ce18fd390c1217708e846579e2387f241c1fbb1b814" }, "downloads": -1, "filename": "lru-dict-1.1.2.tar.gz", "has_sig": false, "md5_digest": "aaae00648873610f56634af123f475bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8284, "upload_time": "2015-09-24T08:57:06", "url": "https://files.pythonhosted.org/packages/9c/df/9229a597a5ee9068c8681c8b88a4fbe1f05cc1e820061625caf1c17e23f7/lru-dict-1.1.2.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "ff61d0109e3e9b75376fa44422f25e89", "sha256": "7502f70f6139f8a989074a9eb2244e21338a9f7cb73f2b4cef4325adb196f761" }, "downloads": -1, "filename": "lru-dict-1.1.3.tar.gz", "has_sig": false, "md5_digest": "ff61d0109e3e9b75376fa44422f25e89", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8493, "upload_time": "2015-11-10T10:39:42", "url": "https://files.pythonhosted.org/packages/b1/ac/239be45c104c612ef547e5db468567c0ff512bae794ec644f0dc90256ed8/lru-dict-1.1.3.tar.gz" } ], "1.1.4": [ { "comment_text": "", "digests": { "md5": "95ed142416b32c4b03dd8e7dae924f38", "sha256": "c64937e2697c84eee79c66c6fb94c8b962ae6104b760f3e878d0af229395774e" }, "downloads": -1, "filename": "lru-dict-1.1.4.tar.gz", "has_sig": false, "md5_digest": "95ed142416b32c4b03dd8e7dae924f38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8119, "upload_time": "2016-06-17T04:36:28", "url": "https://files.pythonhosted.org/packages/c3/b7/4e5bcbdfdc2227001f897051d6f4c83f9d236fe89a9df74da07cc3d9bac8/lru-dict-1.1.4.tar.gz" } ], "1.1.5": [ { "comment_text": "", "digests": { "md5": "1a111d8c36b234491ba0f4210cf53850", "sha256": "d01facbd7daad1b45360a256c68295839bb9576d71d6a165f6e4c7982417a44c" }, "downloads": -1, "filename": "lru-dict-1.1.5.tar.gz", "has_sig": false, "md5_digest": "1a111d8c36b234491ba0f4210cf53850", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8640, "upload_time": "2016-10-08T22:30:28", "url": "https://files.pythonhosted.org/packages/b4/4b/848b90d15a6e348e7cf309a7c26ed56ae76c6a571cae8eabdba31fb43538/lru-dict-1.1.5.tar.gz" } ], "1.1.6": [ { "comment_text": "", "digests": { "md5": "b33f54f1257ab541f4df4bacc7509f5a", "sha256": "365457660e3d05b76f1aba3e0f7fedbfcd6528e97c5115a351ddd0db488354cc" }, "downloads": -1, "filename": "lru-dict-1.1.6.tar.gz", "has_sig": false, "md5_digest": "b33f54f1257ab541f4df4bacc7509f5a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9434, "upload_time": "2016-12-10T00:55:43", "url": "https://files.pythonhosted.org/packages/00/a5/32ed6e10246cd341ca8cc205acea5d208e4053f48a4dced2b1b31d45ba3f/lru-dict-1.1.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b33f54f1257ab541f4df4bacc7509f5a", "sha256": "365457660e3d05b76f1aba3e0f7fedbfcd6528e97c5115a351ddd0db488354cc" }, "downloads": -1, "filename": "lru-dict-1.1.6.tar.gz", "has_sig": false, "md5_digest": "b33f54f1257ab541f4df4bacc7509f5a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9434, "upload_time": "2016-12-10T00:55:43", "url": "https://files.pythonhosted.org/packages/00/a5/32ed6e10246cd341ca8cc205acea5d208e4053f48a4dced2b1b31d45ba3f/lru-dict-1.1.6.tar.gz" } ] }