{ "info": { "author": "Jeff Ward", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Topic :: Utilities" ], "description": "Copyright 2017 Jeff Ward\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\neither express or implied. See the License for the specific\nlanguage governing permissions and limitations under the License.\n\n\nThis is an extremely *basic* implementation of a value and function cache. There are better tools out there I am sure.\nIt is in initial development so there are likely major bugs. I may update this as I use it more, but you are safest\nexpecting no further updates.\n\nThe intent behind this package is to provide something that in one line decorates a function call to, as transparently\nas possible, cache its results. The use case I built this around was searching hyperparameters. By wrapping your\nmodel call in this cache you can quickly implement either random search, or even MCTS, where previously generated\nresults are automatically re-loaded without putting custom caching logic into your code. Additionally, if you\nare performing grid searches with parameter values from a-c and later realizae you wanted to search from a-m then\nusing this function cache allows you to re-test and automatically re-load existing results while only calculating\nnew results.\n\nA simple example::\n\n import easycache as ec\n import time\n\n\n def myExpensiveFunction(cost, extraCost=0.0):\n time.sleep(cost)\n time.sleep(extraCost)\n print(\"This was expensive!\")\n return cost\n\n def gridSearchExample(paramA, paramB):\n \"\"\" Simulates a grid search over parameter values\n\n :param paramA: list of values\n :param paramB: list of values\n :return:\n \"\"\"\n cachedEF = ec.cacheFunction(myExpensiveFunction, 'example.pkl', name=\"myExpensiveFunction\")\n\n bestValue = None\n bestA = None\n bestB = None\n for a in paramA:\n for b in paramB:\n newValue = cachedEF(a+b)\n if bestValue is None or newValue > bestValue:\n bestValue = newValue\n bestA = a\n bestB = b\n return bestValue, bestA, bestB\n\n print(\"Best Value={} using A={} and B={}\".format(*gridSearchExample([.1, .2], [.01, .02])))\n\n #Oh, we REALLY should have searched more! This should only run the 2 new tests\n print(\"Best Value={} using A={} and B={}\".format(*gridSearchExample([.1, .2], [.01, .02, .003])))\n\nOf course you can do other things::\n\n def runClass(cache):\n print(\"Cached Value={}\".format(cache.someValue))\n #Assignment will flush the cache.\n #If this is a complex object you will need to manually flush if internal state changes\n cache.someValue = 12\n print(\"Cached Value={}\".format(cache.someValue))\n print(\"peek={}\".format(cache.myExpensiveFunction(.5, mode=\"cache_peek\")))\n cache.myExpensiveFunction(.5)\n\n def classExample():\n cache = ec.EasyCache(\"exampleClass.pkl\")\n cache.clearCache()\n cache.cacheFunction(myExpensiveFunction, name=\"myExpensiveFunction\")\n cache.cacheProperty(\"someValue\", initialValue=42)\n runClass(cache)\n runClass(cache)\n cache.myExpensiveFunction(.5,mode=\"force_run\")\n #need 'mode' for a parameter? change it\n cache.modeArg='mode2'\n cache.myExpensiveFunction(.5,mode2=\"clear_clear\")\n cache.myExpensiveFunction(.5)\n del cache.someValue\n del cache.myExpensiveFunction\n\n classExample()\n\nAnd you can ignore parameters for the purpose of caching::\n\n def myComplexExpensiveFunction(cost, uglyState, moreUglyState=None):\n time.sleep(cost)\n print(\"This was expensive and complex!\")\n return cost\n\n def ignoreParametersExample():\n cachedCEF = ec.cacheFunction(myComplexExpensiveFunction, 'example.pkl', name=\"myComplexExpensiveFunction\", ignoreArgs=(1,), ignorekwArgs=('moreUglyState'))\n cachedCEF(.5, 'ignored for caching purposes', moreUglyState='also ignored for caching purposes')\n cachedCEF(.5, 'still cached', moreUglyState='still cached')\n cachedCEF(.1, 'this wasn\\'t cached', moreUglyState='because the arg changed')\n\n ignoreParametersExample()", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/GreedyUser/easycache", "keywords": "", "license": "Apache License, Version 2.0", "maintainer": "", "maintainer_email": "", "name": "easycache", "package_url": "https://pypi.org/project/easycache/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/easycache/", "project_urls": { "Homepage": "https://bitbucket.org/GreedyUser/easycache" }, "release_url": "https://pypi.org/project/easycache/0.1.5/", "requires_dist": null, "requires_python": "", "summary": "Implementation of a simple persistent value and function cache.", "version": "0.1.5" }, "last_serial": 2760805, "releases": { "0.1.0a1": [ { "comment_text": "", "digests": { "md5": "a85dd3b104f4d83aa65ae40f72d22bd2", "sha256": "e3df2163c7680b3303f266135ea6a4f76268d75dd3e685b9451480e05800b317" }, "downloads": -1, "filename": "easycache-0.1.0a1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a85dd3b104f4d83aa65ae40f72d22bd2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8820, "upload_time": "2017-03-30T00:17:46", "url": "https://files.pythonhosted.org/packages/7e/6a/2255ae01b8bcb57f7e53e12335a716a4fcfd5b0879d303c10672ff2ecfa0/easycache-0.1.0a1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cc7d34329e423a94deff1fd291ca916e", "sha256": "6e8699664a58b3e78dae7318012bca45b1d00fd871c0ea3f35710162974b4bee" }, "downloads": -1, "filename": "easycache-0.1.0a1.zip", "has_sig": false, "md5_digest": "cc7d34329e423a94deff1fd291ca916e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10921, "upload_time": "2017-03-30T00:17:47", "url": "https://files.pythonhosted.org/packages/0b/6e/1ab93cd2013c52224d50d29b843f33220f025f2fb04bca8f8cd41e196cc9/easycache-0.1.0a1.zip" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "82d64a0c70ac3e6acc8bfef26b368819", "sha256": "46c8c11c8a8738268d2f4fb9a51c761845c7e0e61c03d515d40395b2414b751b" }, "downloads": -1, "filename": "easycache-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "82d64a0c70ac3e6acc8bfef26b368819", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9937, "upload_time": "2017-03-30T09:09:19", "url": "https://files.pythonhosted.org/packages/3c/15/90c6cd3fa0d9257894f7c823f48d80d676defc7791d881a2b698f884e95d/easycache-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e2133c41fd02be60cea6a95966eed6a5", "sha256": "9981b3cdf2b53b8f3fc7fe82c321170b4d43e15f9290e7983cbd7709583ed799" }, "downloads": -1, "filename": "easycache-0.1.1.zip", "has_sig": false, "md5_digest": "e2133c41fd02be60cea6a95966eed6a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12341, "upload_time": "2017-03-30T09:09:21", "url": "https://files.pythonhosted.org/packages/ae/8a/464d3b75a618333159c5c38b399b969a56f89f1989553b0539dcaf221ec8/easycache-0.1.1.zip" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "c165f55c12e33ad08cde86fa1f7c8774", "sha256": "3fa551ae253b49eacb4da9b95c0968925ad32a19be60b669859bb6d4f3c51c32" }, "downloads": -1, "filename": "easycache-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c165f55c12e33ad08cde86fa1f7c8774", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12343, "upload_time": "2017-03-30T12:08:34", "url": "https://files.pythonhosted.org/packages/8f/85/9d10808f18521bcc9557cd5718bbd87e634f979c67aab4b6c15b4d47ffd2/easycache-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4be0bb5a9296f2969b61bd3d92d9de14", "sha256": "f9e6ac85965eecabc2e7ede976ef58e4ba6ff8e3b0c815a026e1932377a50d5b" }, "downloads": -1, "filename": "easycache-0.1.2.zip", "has_sig": false, "md5_digest": "4be0bb5a9296f2969b61bd3d92d9de14", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10325, "upload_time": "2017-03-30T12:08:36", "url": "https://files.pythonhosted.org/packages/1b/82/d44ddd04ec36551f7f13c2429dfaebdb8707e302a85becf168b12ea06b48/easycache-0.1.2.zip" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "2b5cbb9cfae0c40e166ed4808c57eee6", "sha256": "d5b2e323c4ad2f1c8ba8111d4b727313464ce26ca5dfd62dd238f18e66289c9d" }, "downloads": -1, "filename": "easycache-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2b5cbb9cfae0c40e166ed4808c57eee6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7852, "upload_time": "2017-03-30T13:19:50", "url": "https://files.pythonhosted.org/packages/d9/f5/04ea3ee488463f3327c9ff6d1decf099a6542e48ba5ddd2f16c2e7ec520e/easycache-0.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "870fa1c03fa20d2b7a2cc6d5aa084c08", "sha256": "9800a6f27e3701d7ffe9c6fc447fcb0adf9666a7b35d6fa721028976e1e1f6a0" }, "downloads": -1, "filename": "easycache-0.1.3.tar.gz", "has_sig": false, "md5_digest": "870fa1c03fa20d2b7a2cc6d5aa084c08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5012, "upload_time": "2017-03-30T13:19:51", "url": "https://files.pythonhosted.org/packages/1a/35/6f31f91fce0ceeb79328295098823601e803e7f8c2d5c4bafb7f15dddd50/easycache-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "35e04fc15adc8143492c3e260dcbefdd", "sha256": "46f24cdd4513bb4634122140446262e7d582cb2433c7327cf75113d7f8f1045b" }, "downloads": -1, "filename": "easycache-0.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "35e04fc15adc8143492c3e260dcbefdd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7871, "upload_time": "2017-04-05T13:30:58", "url": "https://files.pythonhosted.org/packages/c6/6c/2bcc1c3361c77883e4c0720ecff036699c45341b0487dbc35db18804fb2a/easycache-0.1.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c210c19fc0a744bbcc7a28d52ea89c34", "sha256": "43a5070d881a0e2050e754d65f53923d5d0c406af9de3e195cffd23a3d79556e" }, "downloads": -1, "filename": "easycache-0.1.4.tar.gz", "has_sig": false, "md5_digest": "c210c19fc0a744bbcc7a28d52ea89c34", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5020, "upload_time": "2017-04-05T13:31:00", "url": "https://files.pythonhosted.org/packages/02/97/c660973db1ab8c678acdc0b8d016a6d4ee04c346b1979b22711d0fc49e2a/easycache-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "37f8ce03886989520cabdfbf8a343b5a", "sha256": "2c112d109ba3265c3714d6848168337f9a29e8ea45d5df3e16ed0a6130380a52" }, "downloads": -1, "filename": "easycache-0.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "37f8ce03886989520cabdfbf8a343b5a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7871, "upload_time": "2017-04-07T18:25:42", "url": "https://files.pythonhosted.org/packages/6b/ee/88051ba93c7d107d1cb20f3ce69bfec112869344222d58d82538ee1b57ff/easycache-0.1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0d068c321cf81ab500e4744a4313985b", "sha256": "832e88f1df96908f6eb89181ba78758bec876e27aa815c0042dc8bc78a0881b9" }, "downloads": -1, "filename": "easycache-0.1.5.tar.gz", "has_sig": false, "md5_digest": "0d068c321cf81ab500e4744a4313985b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5015, "upload_time": "2017-04-07T18:25:43", "url": "https://files.pythonhosted.org/packages/f5/a5/ca0a44b668910c22c6f3bccaa3b442616a5e9f4cb6564a8d22dc6c28e8ec/easycache-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "37f8ce03886989520cabdfbf8a343b5a", "sha256": "2c112d109ba3265c3714d6848168337f9a29e8ea45d5df3e16ed0a6130380a52" }, "downloads": -1, "filename": "easycache-0.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "37f8ce03886989520cabdfbf8a343b5a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7871, "upload_time": "2017-04-07T18:25:42", "url": "https://files.pythonhosted.org/packages/6b/ee/88051ba93c7d107d1cb20f3ce69bfec112869344222d58d82538ee1b57ff/easycache-0.1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0d068c321cf81ab500e4744a4313985b", "sha256": "832e88f1df96908f6eb89181ba78758bec876e27aa815c0042dc8bc78a0881b9" }, "downloads": -1, "filename": "easycache-0.1.5.tar.gz", "has_sig": false, "md5_digest": "0d068c321cf81ab500e4744a4313985b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5015, "upload_time": "2017-04-07T18:25:43", "url": "https://files.pythonhosted.org/packages/f5/a5/ca0a44b668910c22c6f3bccaa3b442616a5e9f4cb6564a8d22dc6c28e8ec/easycache-0.1.5.tar.gz" } ] }