{"id":15621972,"url":"https://github.com/chrahunt/quicken","last_synced_at":"2025-08-22T19:16:05.376Z","repository":{"id":41092872,"uuid":"161096451","full_name":"chrahunt/quicken","owner":"chrahunt","description":"Make Python apps faster","archived":false,"fork":false,"pushed_at":"2022-12-08T05:42:10.000Z","size":307,"stargazers_count":7,"open_issues_count":22,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T10:41:30.669Z","etag":null,"topics":["cli","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrahunt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-10T00:49:34.000Z","updated_at":"2024-03-20T19:04:44.000Z","dependencies_parsed_at":"2023-01-25T15:31:37.690Z","dependency_job_id":null,"html_url":"https://github.com/chrahunt/quicken","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrahunt%2Fquicken","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrahunt%2Fquicken/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrahunt%2Fquicken/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrahunt%2Fquicken/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrahunt","download_url":"https://codeload.github.com/chrahunt/quicken/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251333783,"owners_count":21572893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","python"],"created_at":"2024-10-03T09:52:26.946Z","updated_at":"2025-04-28T14:47:54.550Z","avatar_url":"https://github.com/chrahunt.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# quicken\n\n[![PyPI Version](https://img.shields.io/pypi/v/quicken.svg)](https://pypi.org/project/quicken/)\n[![Documentation](https://readthedocs.org/projects/quicken/badge/)](https://quicken.readthedocs.io/en/latest/)\n[![Build Status](https://dev.azure.com/chrahunt/quicken/_apis/build/status/chrahunt.quicken?branchName=master)](https://dev.azure.com/chrahunt/quicken/_build/latest?definitionId=1\u0026branchName=master)\n[![Python Versions](https://img.shields.io/pypi/pyversions/quicken.svg)](https://pypi.org/project/quicken/)\n\nMake Python tools start fast.\n\nWhen a quickened script is executed the first time it starts a server in the\nbackground, paying a one time cost to speed up execution for every other execution.\n\nQuicken only speeds up applications on Linux, but transparently falls back\nto executing scripts directly on unsupported platforms, with minimal overhead.\n\nGenerally, an application can benefit if:\n\n1. It takes more than 100ms to start on an average machine\n1. `python -X importtime` shows that the startup time is related to module\n   importing\n\nTo see how fast an app can be, check out the latest benchmark results in\n[CI](https://dev.azure.com/chrahunt/quicken/_build/latest?definitionId=1\u0026branchName=master) and\ninterpretation in wiki [here](https://github.com/chrahunt/quicken/wiki/Benchmark-interpretation).\n\n## Usage\n\n### `quicken` CLI\n\nThe `quicken` command can be use to quicken plain Python scripts that look like\n\n```python\n# script.py\n...\n\ndef main():\n    pass\n\n\nif __name__ == '__main__':\n    main()\n```\n\nRunning `quicken run --file script.py` followed by arguments will start the application server and\nrun all code before `if __name__ == '__main__'`. For the first and subsequent commands, only\nthe code in `if __name__ == '__main__'` will be executed. If the script is updated then a new\nserver will be started.\n\nTo see the status of the server: `quicken status --file script.py`\n\nTo stop the server: `quicken stop --file script.py`\n\nThe server is identified using the full path to the script.\n\n#### Note\n\n1. `__file__` is set to the full, resolved path to the file provided to `--file`, unlike\n   Python which sets it to the path provided on the command line. This is so the\n   code before `if __name__ == '__main__'` and the code after it see the same path\n   even if changing directories or the path provided to the command.\n\n### `quicken.script`\n\n`quicken.script` can wrap `console_scripts` as supported by several Python packaging tools.\n\nThe `console_script`/entrypoint format is `quicken.script:module.path._.function.path`.\nFor example, if our console script is `hello=hello.cli:main`, then we would use\n`helloc=quicken.script:hello.cli._.main`.\n\nOnce set up, we can use `helloc` just like `hello`, but it should be faster after the\nfirst time.\n\nSince `quicken` is new, it would be wise to provide a second command for testing as\nabove, instead of only having a quicken-based command. We use a `c` suffix since\nit's a `c`lient.\n\nIf using setuptools (`setup.py`):\n\n```python\nsetup(\n    # ...\n    entry_points={\n        'console_scripts': [\n            'hello=hello.cli:main',\n            # With quicken\n            'helloc=quicken.script:hello.cli._.main',\n        ],\n    },\n    # ...\n)\n```\n\nIf using poetry\n\n\u003c!--\ndouble-quotes needed for TOML syntax highlighter, otherwise making docs yields\nerror: WARNING: Could not lex literal_block as \"toml\". Highlighting skipped.\n--\u003e\n```toml\n[tools.poetry.scripts]\nhello = \"hello.cli:main\"\n# With quicken\nhelloc = \"quicken.script:hello.cli._.main\"\n```\n\nIf using flit\n\n```toml\n[tools.flit.scripts]\nhello = \"hello.cli:main\"\n# With quicken\nhelloc = \"quicken.script:hello.cli._.main\"\n```\n\n### `quicken.ctl_script`\n\nSimilar to the above, using `quicken.ctl_script` provides a CLI to stop and\ncheck the status of a quicken server.\n\nSetuptools example:\n\n```python\nsetup(\n    ...\n    entry_points={\n        'console_scripts': [\n            'hello=hello.cli:main',\n            # With quicken\n            'helloc=quicken.script:hello.cli._.main',\n            # Server control command\n            'helloctl=quicken.ctl_script:hello.cli._.main',\n        ],\n    },\n    ...\n)\n```\n\nThen we can use `helloctl status` to see the server status information and\n`helloctl stop` to stop the application server.\n\n### Options\n\nQuicken has several options regardless of how it is invoked:\n\n* logging - set `QUICKEN_LOG_FILE` to an absolute file path and debug logs will\n  be traced to it. Note that server logs will only be traced if this environment\n  variable is set for the command that starts the server.\n* idle timeout - by default any quicken server will shut down after 24 hours of\n  inactivity. This can be changed by setting `QUICKEN_IDLE_TIMEOUT` to the desired\n  time (in seconds). This will only take effect if this environment variable is set\n  for the command that starts the server.\n\n# Why\n\nPython command-line tools can feel slow. There are tricks that can be used to\nspeed up startup, but implementing them in individual packages is not scalable,\nand can slow development. The purpose of this project is:\n\n1. provide one way to speed up app startup, with a focus on strategies that\n   can apply across a large number of applications using normal Python\n   development conventions\n1. find areas of improvement that can be folded back into Python itself\n1. make it easier to focus on application logic and not startup time concerns\n\n# Limitations\n\n* Unix only.\n* Debugging may be less obvious for end users or contributors.\n* Access to the socket file implies access to the server and ability to run commands. The library tries to\n  mandate that the directory used for runtime files is only owned by the user, for best results use\n  `XDG_RUNTIME_DIR` as provided by `pam_systemd` or the equivalent for your distribution.\n\n# Tips\n\n* Profile import time with -X importtime, see if your startup is actually the\n  problem. If it's not then this package will not help you.\n* Ensure your package can be built as a wheel, even if it's not distributed as\n  one. When wheels are installed they create scripts that do not import `pkg_resources`,\n  which can save 60ms+ depending on disk speed and caching.\n\n# Development\n\n```shell\npoetry install\npoetry run pytest -ra\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrahunt%2Fquicken","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrahunt%2Fquicken","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrahunt%2Fquicken/lists"}