{ "info": { "author": "Python Developers", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "[![Build Status](https://travis-ci.org/pfalcon/python-compiler.png?branch=master)](https://travis-ci.org/pfalcon/python-compiler)\n\nPython Bytecode Compiler Written in Python\n==========================================\n\nThis is WIP port of Python2 stdlib\n[compiler](https://docs.python.org/2/library/compiler.html) package\nto Python3.\n\nMotivation: to have an easily hackable Python compiler for experimenting\n(e.g. various optimizations, instrumentation, semantic variants, etc.)\n\nThe porting project concentrates on the conversion of AST (as provided by\nthe builtin \"ast\" module) to bytecode and code objects. The original Python2\npackage included another important part: conversion of concrete parse tree\ninto Abstract Syntax Tree (AST). While it would be interesting to ultimately\nhave complete pure-Python closed loop for Python compilation, to keep this\nspecific project maintainable, lexing, parsing, AST building are outside\nof its scope. Other projects are welcome to provide integrated maintainable\nsolutions for those areas (indeed, generic/non-integrated solutions for them\ndefinitely exist).\n\nShort-term goals:\n\n* Port the original \"compiler\" package to work with AST as produced by\n Python3's \"ast\" module.\n* Initially, implement support for Python3.5 syntax and bytecode.\n* Cleanup the original code.\n\nHistory of Python2 \"compiler\" package:\n\n1. The code is based on earlier work done by Greg Stein and Bill Tutt\nfor Python2C (aka Py2C aka p2c) project circa 1997-1999. That code however\ndidn't include bytecode compiler, but just transformer.py module, which\nconverted low-level Python parse tree, as produced by the built \"parser\"\nmodule, into a higher-level Abstract Syntax Tree (AST). The Python2C\nproject itself generated C code from this AST.\n2. Actual bytecode compiler was started and largely written by Jeremy\nHylton. Initial commits importing Python2C files and starting pycodegen.py\nwere made on 2000-02-04.\n3. 66 commits were made in 2000, 73 in 2001, 10 in 2002, 6 in 2003,\n15 in 2004, 9 in 2005, 51 in 2006, 16 in 2007.\n4. In May 2007, complaints are heard that it's hard to maintain and regularly\nbroken: https://mail.python.org/pipermail/python-3000/2007-May/007575.html\n5. Those transformed into an entry in [PEP3108](https://www.python.org/dev/peps/pep-3108/)\nfor its removal.\n6. Removed in of 3.x branch in revision a8add0ec5ef05c26e1641b8310b65ddd75c0fec3\non 2007-05-14.\n7. The funtionality wasn't totally gone, instead functionality of internal\nC-based compiler was exposed in a similar fashion (albeit with changed/cleaned\nup API). E.g., compiler.ast and compiler.transformer was replaced with\nbuiltin \"_ast\" module (in other words, AST node type definitions and\ntransformation of parse tree to AST are now done on C level). compiler.visitor\nwas replaced with Python-level \"ast\" module. Compilation of AST into bytecode\nis handled using builtin compile() function with suitable parameters.\n\nUsage\n-----\n\nCurrently, the package is intended to work with CPython3.5 only.\n\n```\npython3.5 -m compiler --help\npython3.5 -m compiler \n```\n\nBy default, the command above compiles source to in-memory code objects\nand executes it. If `-c` switch is passed, instead of execution, it will\nbe saved to `.pyc` file. If `--dis` is passed, code will be disassembed\nbefore executing/saving.\n\nRunning Tests\n-------------\n\nThe projects includes a builtin test corpus of various syntactic constructs\nto verify codegeneration against reference output produced by CPython3.5.\nCurrently, the project does not include peephole optimizer as included as\na postprocessing pass in CPython. This means that testing should happen\nagainst modified CPython3.5 build with the peephole optimizer disabled.\n\nThe patch is available at https://github.com/pfalcon/cpython/tree/3.5-noopt\nThis repository includes `build-cpython-compiler.sh` helper script to\ndownload and build it. It will produce a `python3.5-nopeephole` symlink\nin the top-level directory, where scripts below expect to find it.\n\nTo produce reference code generation output from python3.5-nopeephole, run:\n\n~~~\n./test_testcorpus_prepare.py\n~~~\n\nThis needs to be done once. Afterwards, you can run\n\n~~~\n./test_testcorpus_run.py\n~~~\n\nto compare the output produced by this compiler package against the\nreference.\n\nAuthorship and Licensing Info\n-----------------------------\n\nThe source code is based on the \"compiler\" package from Python2 standard\nlibrary. It is licensed under Python Software Foundation License v2.\nSee complete licensing terms and details in file LICENSE.\n\nThe \"compiler\" package is a result of dedicated work of a number of\nindividuals, listed below (based on the git history of the official\nCPython repository).\n\nPorting of the code to Python3 and further maintenance is handled by\nPaul Sokolovsky.\n\nContributors to Python2 version of the package:\n\n```\n$ git clone https://github.com/python/cpython\n$ cd cpython\n$ git checkout 2.7\n$ git log --follow Lib/compiler | grep ^Author | sed -e 's/<.*>//' | sort | uniq -c | sort -n -r\n# Email addresses not included to minimize spam\n 143 Author: Jeremy Hylton\n 18 Author: Neal Norwitz\n 18 Author: Guido van Rossum\n 17 Author: Georg Brandl\n 11 Author: Tim Peters\n 9 Author: Thomas Wouters\n 7 Author: Neil Schemenauer\n 6 Author: Michael W. Hudson\n 6 Author: Martin v. L\u00f6wis\n 4 Author: Brett Cannon\n 3 Author: Nick Coghlan\n 3 Author: Antoine Pitrou\n 2 Author: Raymond Hettinger\n 2 Author: Ezio Melotti\n 2 Author: Christian Heimes\n 2 Author: Benjamin Peterson\n 2 Author: Anthony Baxter\n 2 Author: Andrew M. Kuchling\n 2 Author: Alexandre Vassalotti\n 1 Author: Serhiy Storchaka\n 1 Author: Phillip J. Eby\n 1 Author: Jeffrey Yasskin\n 1 Author: Gustavo Niemeyer\n 1 Author: Greg Stein\n 1 Author: Facundo Batista\n 1 Author: Eric Smith\n 1 Author: Collin Winter\n 1 Author: Barry Warsaw\n 1 Author: Amaury Forgeot d'Arc\n```\n\nRelated Projects\n----------------\n\nAka \"why I took Python2's compiler package and spent all this effort on it\ninstead of using something else\".\n\n* [PyPy](https://bitbucket.org/pypy/pypy) is the obvious direction of thought.\n PyPy is a very advanced and big project. Somewhere in there a small hadron\n collider may be lurking. But what if you want a simple Python compiler\n without a hadron collider? You may be out of luck to extract it, or at\n least I was.\n* [YaPyPy](https://github.com/Xython/YAPyPy) - looks absolutely great, but\n its docs miss to explain how to actually run it. I mean, that small part\n of docs (README) which is written in English. There're more docs in Chinese,\n but unfortunately, I can't read it.\n* [tailbiter](https://github.com/darius/tailbiter) is a great project\n showing how to develop a Python bytecode compiler from scratch, and is\n highly recommended for that purpose. But I wanted to get a \"production\n ready\" (read: behaving the same way as CPython's) compiler in reasonable\n time with reasonable effort, not write one from scratch.", "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/pfalcon/python-compiler", "keywords": "", "license": "Python", "maintainer": "Paul Sokolovsky", "maintainer_email": "pfalcon@users.sourceforge.net", "name": "python-compiler", "package_url": "https://pypi.org/project/python-compiler/", "platform": "", "project_url": "https://pypi.org/project/python-compiler/", "project_urls": { "Homepage": "https://github.com/pfalcon/python-compiler" }, "release_url": "https://pypi.org/project/python-compiler/1.1/", "requires_dist": null, "requires_python": "", "summary": "Python bytecode compiler written in Python", "version": "1.1" }, "last_serial": 4787953, "releases": { "0.0": [ { "comment_text": "", "digests": { "md5": "aa06428e7b9b37a8f288b609d8f037d1", "sha256": "ecaf81ce7621ad17ee2cddfb9b83180b2685822c2112948bbb4d66c3b60b0e3e" }, "downloads": -1, "filename": "python-compiler-0.0.tar.gz", "has_sig": false, "md5_digest": "aa06428e7b9b37a8f288b609d8f037d1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45103, "upload_time": "2019-01-21T00:15:09", "url": "https://files.pythonhosted.org/packages/d9/5b/20026bb4ac01d9f236c8766f699b5bf3fa068361bc64eaa1744ddb9feeeb/python-compiler-0.0.tar.gz" } ], "0.0.1": [ { "comment_text": "", "digests": { "md5": "b4625bb76bf080a150a755990f4dd4df", "sha256": "8c251529bafc004abc44d42db28483ae48a19bc54b0866d8c94f68250c4c1465" }, "downloads": -1, "filename": "python-compiler-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b4625bb76bf080a150a755990f4dd4df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45131, "upload_time": "2019-01-21T00:17:18", "url": "https://files.pythonhosted.org/packages/71/42/cdb13d57ecb9cb65055f5634e74e161350cf118cfb3f36ac02d34aa7bfe9/python-compiler-0.0.1.tar.gz" } ], "0.1": [ { "comment_text": "", "digests": { "md5": "654979386956ba1acd898bb46ace782d", "sha256": "d093b1edc2702f5fc7502a768d58cb88f7023bad2b82e52ad2f8fa1bb805a008" }, "downloads": -1, "filename": "python-compiler-0.1.tar.gz", "has_sig": false, "md5_digest": "654979386956ba1acd898bb46ace782d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45575, "upload_time": "2019-01-21T00:20:14", "url": "https://files.pythonhosted.org/packages/be/5b/5f9990313132206050ee89a744c7e22e62cf9536bd71a3210ff589818853/python-compiler-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "32aa896633d0efb9374ae766f68fe925", "sha256": "a81deddb9f7ca22b2e80d3918c5361e01b6d7855ca87d5d9e3ac7f9a943e8096" }, "downloads": -1, "filename": "python-compiler-0.1.1.tar.gz", "has_sig": false, "md5_digest": "32aa896633d0efb9374ae766f68fe925", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45589, "upload_time": "2019-01-21T00:34:38", "url": "https://files.pythonhosted.org/packages/1f/46/5e9a612a0a1f4a8fc6f87e8382a46c595fe979687f75fe22524c9f28cf1c/python-compiler-0.1.1.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "7a79cd8be73579831c4196faac7b85f1", "sha256": "6219b20c6defeb42fbd2bba7f342e6659175749568521df3c0aea4c3a9585904" }, "downloads": -1, "filename": "python-compiler-1.0.tar.gz", "has_sig": false, "md5_digest": "7a79cd8be73579831c4196faac7b85f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48393, "upload_time": "2019-01-30T20:25:36", "url": "https://files.pythonhosted.org/packages/80/cd/10bce422a3f226e1773fc2998c80af42da7a84fd8678ec0c74e5c8d8d7fb/python-compiler-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "6c261d304e0c9e770daca800425c5f15", "sha256": "1761aff9fd233f5dcfd59e4419e84afc9178dff3a7e3719bc1809d67c56b931c" }, "downloads": -1, "filename": "python-compiler-1.1.tar.gz", "has_sig": false, "md5_digest": "6c261d304e0c9e770daca800425c5f15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33173, "upload_time": "2019-02-06T18:32:33", "url": "https://files.pythonhosted.org/packages/67/7c/e24f1429c6361da73a31b2c82f6cead23caa50d7672bc234f586cb5949cb/python-compiler-1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6c261d304e0c9e770daca800425c5f15", "sha256": "1761aff9fd233f5dcfd59e4419e84afc9178dff3a7e3719bc1809d67c56b931c" }, "downloads": -1, "filename": "python-compiler-1.1.tar.gz", "has_sig": false, "md5_digest": "6c261d304e0c9e770daca800425c5f15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33173, "upload_time": "2019-02-06T18:32:33", "url": "https://files.pythonhosted.org/packages/67/7c/e24f1429c6361da73a31b2c82f6cead23caa50d7672bc234f586cb5949cb/python-compiler-1.1.tar.gz" } ] }