{ "info": { "author": "Brandt Bucher", "author_email": "brandtbucher@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "
\n\nHAX\n===\n\n[![latest version](https://img.shields.io/github/release-pre/brandtbucher/hax.svg?style=for-the-badge&label=latest)![latest release date](https://img.shields.io/github/release-date-pre/brandtbucher/hax.svg?style=for-the-badge&label=released)](https://github.com/brandtbucher/hax/releases)[![build status](https://img.shields.io/github/workflow/status/brandtbucher/hax/CI/master.svg?style=for-the-badge)](https://github.com/brandtbucher/hax/actions)[![issues](https://img.shields.io/github/issues-raw/brandtbucher/hax.svg?label=issues&style=for-the-badge)](https://github.com/brandtbucher/hax/issues)\n\n
\n\n
\n\n
\n\nHAX lets you write compiled bytecode inline with pure Python. It was originally\nbuilt for exploring new improvements to CPython's compiler and peephole\noptimizer.\n\nInstallation\n------------\n\nHAX supports CPython 3.6+ on all platforms.\n\nTo install, just run:\n\n```sh\n$ pip install hax\n```\n\nExample\n-------\n\nConsider the following function; it accepts a sequence of items, and returns a\nlist with each item repeated twice:\n\n```py\ndef doubled(items):\n out = []\n for item in items:\n out += item, item\n return out\n```\n\nFor example, `doubled((0, 1, 2))` returns `[0, 0, 1, 1, 2, 2]`.\n\nWe can make this function faster by keeping `out` on the stack (instead of in a\nlocal variable) and using the `LIST_APPEND` op to build it. HAX makes it\nsimple to inline these instructions:\n\n```py\nfrom hax import *\n\n@hax\ndef doubled(items):\n\n BUILD_LIST(0)\n\n for item in items:\n\n LOAD_FAST(\"item\")\n DUP_TOP()\n LIST_APPEND(3)\n LIST_APPEND(2)\n\n RETURN_VALUE()\n```\n\nWith the help of labeled jump targets (`HAX_LABEL`), the function can be further\nsped up by rewriting the for-loop in bytecode, removing _all_ temporary\nvariables, and operating **entirely on the stack**:\n\n```py\nfrom hax import *\n\n@hax\ndef doubled(items):\n\n BUILD_LIST(0)\n\n LOAD_FAST(\"items\")\n GET_ITER()\n HAX_LABEL(\"loop\")\n FOR_ITER(\"return\")\n\n DUP_TOP()\n LIST_APPEND(3)\n LIST_APPEND(2)\n JUMP_ABSOLUTE(\"loop\")\n\n HAX_LABEL(\"return\")\n RETURN_VALUE()\n```\n\nIt's important to realize that the functions HAX provides (`BUILD_LIST`,\n`LOAD_FAST`, ...) aren't just \"emulating\" their respective bytecode\ninstructions; the `@hax` decorator detects them, and completely recompiles\n`double`'s code to use the _actual_ ops that we've specified here!\n\nThese performance improvements are impossible to get from CPython's compiler and\noptimizer alone.\n\n
\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brandtbucher/hax", "keywords": "bytecode", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "hax", "package_url": "https://pypi.org/project/hax/", "platform": "", "project_url": "https://pypi.org/project/hax/", "project_urls": { "Homepage": "https://github.com/brandtbucher/hax" }, "release_url": "https://pypi.org/project/hax/0.2.4/", "requires_dist": null, "requires_python": "", "summary": "Write compiled bytecode inline with standard Python syntax.", "version": "0.2.4", "yanked": false, "yanked_reason": null }, "last_serial": 9034761, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "d460003b78edad396ead5627307e159b", "sha256": "23c52587b2694a829418ac3c93d3e013bdb82cacfaa0d27b67e2b99fcb4483bc" }, "downloads": -1, "filename": "hax-0.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d460003b78edad396ead5627307e159b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6176, "upload_time": "2019-10-16T08:03:59", "upload_time_iso_8601": "2019-10-16T08:03:59.755866Z", "url": "https://files.pythonhosted.org/packages/26/e5/147ccc9d1848eb9387dd17b3b5af3556ded85963d5ae64aef30f4c85072f/hax-0.0.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a2da1c2e3cbbca8f2d15d0ad020c2744", "sha256": "0c6934e61d5c8f37a017208b0aaea153350a17a807e8e4ea76075fb35f98e5c4" }, "downloads": -1, "filename": "hax-0.0.0.tar.gz", "has_sig": false, "md5_digest": "a2da1c2e3cbbca8f2d15d0ad020c2744", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5217, "upload_time": "2019-10-16T08:04:03", "upload_time_iso_8601": "2019-10-16T08:04:03.974785Z", "url": "https://files.pythonhosted.org/packages/6d/a4/dea3b72755be51e6dfa48596d2cbd104f10f90ea97dbaedefe0227054cdc/hax-0.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "b9c869743c274fa2dac73f5b711529e3", "sha256": "bce5d1e2b2c6c52240c919bc73904e129a1d1079a4f4d605b95355b81581b2d8" }, "downloads": -1, "filename": "hax-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b9c869743c274fa2dac73f5b711529e3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6792, "upload_time": "2019-10-20T14:34:14", "upload_time_iso_8601": "2019-10-20T14:34:14.520712Z", "url": "https://files.pythonhosted.org/packages/3e/23/3545af286c47344aa37dea9a3bb09fbfff413bb37441d2b65166b39df955/hax-0.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "be45c1fbb8e9d63e15e8de61c3fdec86", "sha256": "789f19638d26a90e530b8d18fa9223e6c8152b16863512f868517869eb82a9eb" }, "downloads": -1, "filename": "hax-0.1.0.tar.gz", "has_sig": false, "md5_digest": "be45c1fbb8e9d63e15e8de61c3fdec86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5843, "upload_time": "2019-10-20T14:34:18", "upload_time_iso_8601": "2019-10-20T14:34:18.354559Z", "url": "https://files.pythonhosted.org/packages/53/90/56376e4b153948bc01264fade3738243c48484dde810722c7a567f832c59/hax-0.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ddbc3518d54af838c59af004092db9fe", "sha256": "fefbab0f59b41796c01482cdeefe300339541fec20431124482efaf258f999f6" }, "downloads": -1, "filename": "hax-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ddbc3518d54af838c59af004092db9fe", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7465, "upload_time": "2019-10-25T05:59:16", "upload_time_iso_8601": "2019-10-25T05:59:16.120976Z", "url": "https://files.pythonhosted.org/packages/44/ce/f13c8da133b36220d305f4c23ccc519b9a171d12c0874e3605c893e80892/hax-0.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a564f05a178062bb68240b35a9473588", "sha256": "99b6a42ade57533fd485018d38915003681799ee0cb99714bbb4c377876f628a" }, "downloads": -1, "filename": "hax-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a564f05a178062bb68240b35a9473588", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6516, "upload_time": "2019-10-25T05:59:17", "upload_time_iso_8601": "2019-10-25T05:59:17.775624Z", "url": "https://files.pythonhosted.org/packages/47/21/84f49393ca6a8ee2a5dba91cf61e459945bbf804ad1563c947e8968fef4b/hax-0.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "1d46938d020d6612ec31611d3178a737", "sha256": "e4882c4ff0c7a58c4d004c09b0660be4e2740b6b6a830971e821ce8d5334c1b5" }, "downloads": -1, "filename": "hax-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1d46938d020d6612ec31611d3178a737", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10592, "upload_time": "2019-11-01T16:28:19", "upload_time_iso_8601": "2019-11-01T16:28:19.343142Z", "url": "https://files.pythonhosted.org/packages/aa/67/530901a086fea7de593196ac77633470d60144670f222e1ba037a97deaed/hax-0.2.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "e3fecf6aaf869bf108057a40ef7be414", "sha256": "23f84a289a0b42c8d067e7785d416d9c9335d16167539b16314dfd6e230173a9" }, "downloads": -1, "filename": "hax-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e3fecf6aaf869bf108057a40ef7be414", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9853, "upload_time": "2019-11-01T16:28:21", "upload_time_iso_8601": "2019-11-01T16:28:21.276098Z", "url": "https://files.pythonhosted.org/packages/ee/40/26b2cc74223c1399ba7e14bf6b6d1afa7cd40f2765b98cfbef445e507adc/hax-0.2.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "99263098068246b4656edce26c54b4a6", "sha256": "f68793fca8f4e45f42e1ec6139baf36703e3b22fc7e5eec906c0544d414bd835" }, "downloads": -1, "filename": "hax-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "99263098068246b4656edce26c54b4a6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10747, "upload_time": "2020-12-16T06:24:40", "upload_time_iso_8601": "2020-12-16T06:24:40.680505Z", "url": "https://files.pythonhosted.org/packages/f9/98/fd5eb98f25b156abf4b9c2b8dd25ae73c5c0850338957a59f2d54519fec0/hax-0.2.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "14df1e877aea444fd5a956bd3f9e9313", "sha256": "a4427ac4fc64b7893c488743dcffa6cf44e6b6cbcaf925c2fcd3357106f51e00" }, "downloads": -1, "filename": "hax-0.2.1.tar.gz", "has_sig": false, "md5_digest": "14df1e877aea444fd5a956bd3f9e9313", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10277, "upload_time": "2020-12-16T06:24:41", "upload_time_iso_8601": "2020-12-16T06:24:41.514119Z", "url": "https://files.pythonhosted.org/packages/cf/1a/893419c04952484d031f74dcd3db2a2ba5364c7c00f0e2b8086d849d0a32/hax-0.2.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "4a7ab901ff7ec683387a028992217615", "sha256": "2da8898f415262bdd7e70662a27224084499a90b4db30fc559313d5bc7b92243" }, "downloads": -1, "filename": "hax-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "4a7ab901ff7ec683387a028992217615", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10963, "upload_time": "2020-12-18T17:25:36", "upload_time_iso_8601": "2020-12-18T17:25:36.129829Z", "url": "https://files.pythonhosted.org/packages/50/df/484518abb1fd57cc13e2d7ce2a4883bc589e27735dfdb8685800888b137d/hax-0.2.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "e539720db767c17d10e0dace0e4faf54", "sha256": "832427051d8f36a3e948f7d6e4f493196d9a2dc669c90c683e7867f912ef7ee5" }, "downloads": -1, "filename": "hax-0.2.2.tar.gz", "has_sig": false, "md5_digest": "e539720db767c17d10e0dace0e4faf54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10489, "upload_time": "2020-12-18T17:25:37", "upload_time_iso_8601": "2020-12-18T17:25:37.208328Z", "url": "https://files.pythonhosted.org/packages/76/95/942ab6c0fec7934d2f99f829e46608804fa0ccb7476110bf0f0439c9af64/hax-0.2.2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "2241a40c944f5f2395e2bb1e3e5cf26b", "sha256": "c0249b123fd247971c1bad19e86d6440d3a10585e19639ee40d58441537289fa" }, "downloads": -1, "filename": "hax-0.2.3-py3-none-any.whl", "has_sig": false, "md5_digest": "2241a40c944f5f2395e2bb1e3e5cf26b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11349, "upload_time": "2020-12-31T17:20:33", "upload_time_iso_8601": "2020-12-31T17:20:33.787574Z", "url": "https://files.pythonhosted.org/packages/09/e4/68745564dafdffba86d4b297cca5067ae89e4b93ec21cb9ae5bfebb9e3d5/hax-0.2.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "0844914ad39776d7fc27bd23b1114214", "sha256": "4bc9c31469f8493f7ceae8ec660309a13ede222c007a7ac11fe5f8060b5ada0a" }, "downloads": -1, "filename": "hax-0.2.3.tar.gz", "has_sig": false, "md5_digest": "0844914ad39776d7fc27bd23b1114214", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10776, "upload_time": "2020-12-31T17:20:34", "upload_time_iso_8601": "2020-12-31T17:20:34.643825Z", "url": "https://files.pythonhosted.org/packages/a1/02/4913570017b4b92050c5db1ba007edce0104a8cad25dcb1bf4eb19c0f65d/hax-0.2.3.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "b748b9d4b79b4db8388dc0020ec79a0a", "sha256": "fd509f2be238363433ab2fe0998071951187742a778f2eaf8710aaf86a5d9308" }, "downloads": -1, "filename": "hax-0.2.4-py3-none-any.whl", "has_sig": false, "md5_digest": "b748b9d4b79b4db8388dc0020ec79a0a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12131, "upload_time": "2021-01-02T01:21:11", "upload_time_iso_8601": "2021-01-02T01:21:11.993287Z", "url": "https://files.pythonhosted.org/packages/62/a8/453f6486d7cae2ec09ffb28d94bc0ea5c58aa6e1c12d09f3d98e80fb929c/hax-0.2.4-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "24ae95725b2b1064f793a43501827e01", "sha256": "3a617c80f1269f87a006f46734d5a2f9af88f8929a83a5c7599574a3eeea2b6d" }, "downloads": -1, "filename": "hax-0.2.4.tar.gz", "has_sig": false, "md5_digest": "24ae95725b2b1064f793a43501827e01", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11532, "upload_time": "2021-01-02T01:21:13", "upload_time_iso_8601": "2021-01-02T01:21:13.019952Z", "url": "https://files.pythonhosted.org/packages/79/c3/54184bb1ca07ff7107fa844f78bec62b989164e3c1e86919d4bfcf057155/hax-0.2.4.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b748b9d4b79b4db8388dc0020ec79a0a", "sha256": "fd509f2be238363433ab2fe0998071951187742a778f2eaf8710aaf86a5d9308" }, "downloads": -1, "filename": "hax-0.2.4-py3-none-any.whl", "has_sig": false, "md5_digest": "b748b9d4b79b4db8388dc0020ec79a0a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12131, "upload_time": "2021-01-02T01:21:11", "upload_time_iso_8601": "2021-01-02T01:21:11.993287Z", "url": "https://files.pythonhosted.org/packages/62/a8/453f6486d7cae2ec09ffb28d94bc0ea5c58aa6e1c12d09f3d98e80fb929c/hax-0.2.4-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "24ae95725b2b1064f793a43501827e01", "sha256": "3a617c80f1269f87a006f46734d5a2f9af88f8929a83a5c7599574a3eeea2b6d" }, "downloads": -1, "filename": "hax-0.2.4.tar.gz", "has_sig": false, "md5_digest": "24ae95725b2b1064f793a43501827e01", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11532, "upload_time": "2021-01-02T01:21:13", "upload_time_iso_8601": "2021-01-02T01:21:13.019952Z", "url": "https://files.pythonhosted.org/packages/79/c3/54184bb1ca07ff7107fa844f78bec62b989164e3c1e86919d4bfcf057155/hax-0.2.4.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }