{ "info": { "author": "The xonsh developers", "author_email": "xonsh@googlegroups.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved", "Programming Language :: Python", "Topic :: Utilities" ], "description": "pygments-cache\n==============\nA fast, drop-in replacement for pygments ``get_*()`` and ``guess_*()`` funtions.\n\nThe following pygments API functions are currently supplied here::\n\n from pygments_cache import get_lexer_for_filename, guess_lexer_for_filename\n from pygments_cache import get_formatter_for_filename, get_formatter_by_name\n from pygments_cache import get_style_by_name\n from pygments_cache import get_filter_by_name\n\nThe cache itself is stored at the location given by the ``$PYGMENTS_CACHE_FILE``\nenvironment variable, or by default at ``~/.local/share/pygments-cache/cache.py``.\nThe cache file is created on first use, if it does not already exist.\n\nIf a pygements extentsion is not found in the cache, the API functions listed here\nwill fallback to the original pygments version and the extension will be added to\nthe cache for future use. That is, the cache will discover and save new extensions\nas you would expect.\n\nIf you ever need to reset the cache for some reason, simply delete the\n``$PYGMENTS_CACHE_FILE`` from your file system. The next time you call one of\nthe API functions, the cache will be regenerated. Alternatively, you may\nmanually rebuild the cache (after removing the file) with the ``load_or_build()``\nfunction.\n\nThe cache itself is fully accessible as the ``pygments_cache.CACHE`` dict.\n\nThis project is implement as single file, making it easy to redistribute.\nFeel free to copy this file to your own project!\n\nComparison\n----------\n**NOTE:** All of the following tests were in `xonsh `_.\n\n**TL;DR Table:** All timings in seconds.\n\n================== ======== ===========\n cold hot\n================== ======== ===========\n``pygments`` 0.48 3.09e-3\n``pygments_cache`` 0.03 9.90e-6\n**speedup** **16x** **306x**\n================== ======== ===========\n\n\nFrom a **cold start** (i.e. the first import and use), pygments can take a long\ntime (about half a second) to get a single lexer, as seen below:\n\n.. code-block:: console\n\n $ time -p python -c! from pygments.lexers import get_lexer_for_filename; get_lexer_for_filename('index.html')\n real 0.48\n user 0.46\n sys 0.01\n\nThe pygments-cache project speeds this up considerably, assuming the cache file already exists.\nThe timing can be seen here:\n\n.. code-block:: console\n\n $ time -p python -c! from pygments_cache import get_lexer_for_filename; get_lexer_for_filename('index.html')\n real 0.03\n user 0.03\n sys 0.00\n\nThis represents a **16x** speedup. However, most of the 0.03 sec is actually coming from Python itself starting\nup and shutting down.\n\nA more fair test is to look at how long the ``get_lexer_for_filename()`` function takes to run\nonce Python has been started and the function imported.\n\nFrom a **hot start**, pygments itself tok about 3 ms, as seen below:\n\n.. code-block:: console\n\n $ from pygments.lexers import get_lexer_for_filename\n $ timeit! get_lexer_for_filename('index.html')\n 100 loops, best of 3: 3.09 ms per loop\n\nAlternatively, pygments-cache took only 9.9 \u00b5s, as seen below.\n\n.. code-block:: console\n\n $ from pygments_cache import get_lexer_for_filename\n $ timeit! get_lexer_for_filename('index.html')\n 100000 loops, best of 3: 9.9 \u00b5s per loop\n\nThis is a speedup of **306x**!\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/xonsh/pygments-cache/zipball/0.1.2", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/xonsh/pygments-cache", "keywords": "", "license": "BSD 3-clause", "maintainer": "", "maintainer_email": "", "name": "pygments_cache", "package_url": "https://pypi.org/project/pygments_cache/", "platform": "", "project_url": "https://pypi.org/project/pygments_cache/", "project_urls": { "Download": "https://github.com/xonsh/pygments-cache/zipball/0.1.2", "Homepage": "https://github.com/xonsh/pygments-cache" }, "release_url": "https://pypi.org/project/pygments_cache/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "A fast, drop-in replacement for pygments `get_*()` and `guess_*()` funtions", "version": "0.1.2" }, "last_serial": 4090732, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "6cac14535dcc6b39ebfd91c830bb91e2", "sha256": "93f596b6b3408164ab9e47a3b9417ea1ba7f3b1a0bd1c78cc720274523219e6c" }, "downloads": -1, "filename": "pygments_cache-0.1.0.tar.gz", "has_sig": false, "md5_digest": "6cac14535dcc6b39ebfd91c830bb91e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6396, "upload_time": "2018-06-03T20:14:45", "url": "https://files.pythonhosted.org/packages/c9/2d/efedf99e38ef4b7b9ee9009a4d866fa8e5782098579553e1d4002ec549fa/pygments_cache-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "f33298acbd4a5e168ab5217c5292144b", "sha256": "76ddc14e9f89eac8a6489645e3e7f8b55783ce7ebe276dca26c037f54ff5b265" }, "downloads": -1, "filename": "pygments_cache-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f33298acbd4a5e168ab5217c5292144b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6397, "upload_time": "2018-06-03T22:33:05", "url": "https://files.pythonhosted.org/packages/de/40/fdaec1a9bafa782e1c39bf5af2c160e0e4385ba85ce363a1b45359d6dad0/pygments_cache-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "f61915c4812a16d6cd01b1adc3654617", "sha256": "b1362f0bd46e84a3546c864c4702c18776f8379d04a76393ea672f0ce6642d2e" }, "downloads": -1, "filename": "pygments_cache-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f61915c4812a16d6cd01b1adc3654617", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6455, "upload_time": "2018-07-22T17:59:28", "url": "https://files.pythonhosted.org/packages/69/0e/f9640746480369995f77dd98b0dfa39f9e7cf87822bbdcdeab21aec4c516/pygments_cache-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f61915c4812a16d6cd01b1adc3654617", "sha256": "b1362f0bd46e84a3546c864c4702c18776f8379d04a76393ea672f0ce6642d2e" }, "downloads": -1, "filename": "pygments_cache-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f61915c4812a16d6cd01b1adc3654617", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6455, "upload_time": "2018-07-22T17:59:28", "url": "https://files.pythonhosted.org/packages/69/0e/f9640746480369995f77dd98b0dfa39f9e7cf87822bbdcdeab21aec4c516/pygments_cache-0.1.2.tar.gz" } ] }