Lucian Branescu Mihaila
email: lucian dot braneNOSPAMscu at gmail dot com irc: lucian
Project: Python3 on Parrot
Abstract: This project aims to create a Python3 [Python] compiler and object system that works on parrot.
- (partial) implementation of Python3 on parrot
- exploration of parrot's suitability for another modern scripting language
- stress-test of parrot's bootstrapping capabilities, especially with an already self-hosted, mature language
- (initially) dependant on CPython
- likely slower than other python implementations
- likely incomplete for a long time
- python3-to-parrot compiler written in python3. to be run on CPython
- python3 object system written in winxed/pir/with 6model. to be run on Parrot
- testsuite for primitive python implementations, similar to what pynie has now
- documentation on how to use Python3 on Parrot
The project is necessarily made up of two parts: compiler and object system.
I intend to use an existing compiler [CPython compiler] to parse python code and write a parrot backend, likely generating PIR or Winxed. This "stage 0" compiler will run on CPython and generate PIR, to be compiled and run by parrot. Since it depends on the (now) C-only 'ast' module, it won't be boostrapped in the near future even if Python3 on Parrot is complete enough to otherwise compile itself. This isn't a major issue since 1) python is ubiquitous and 2) the 'ast' module is relativel small and other parties may be interested in a pure-python version.
However, python code requires python core types (an object system) to function. This object system necessarily needs to be written in a Parrot HLL, since Python3 on Parrot wouldn't be bootstrapped yet. While it is possible to write a second Python3-subset compiler, I consider it outside the scope of GSoC. I intend to investigate two options:
use Winxed (and parrot hashes) to implement python objects. I don't expect this to be particularly efficient, but I do expect it to be relatively low-effort and possible even with the limitations Parrot's current object system has.
use 6model. It's full of unknowns and I'm not convinced it can map to Python's object system cleanly and efficiently, in which case it wouldn't be an improvement over parrot's current object system.
The details of the object system can be changed later, ideally after Python3 on Parrot is bootstrapped.
I plan to develop the compiler & object system incrementally, and continuously test them, also against each other. This should improve the quality of the code and provide a better starting point for continuing the project, either by myself or others.
- experiment with and decide between 6model or a custom object system
- experiment with and decide between PIR, PBC or Winxed for compiler backend output
- write new tests or adapt old pynie tests for primitive python features. Even the most basic of tests in the official test suite already depend on a full object system, so a more frugal test suite is necessary for a while.
- make sure all tests pass on good existing Python implementations (CPython, perhaps PyPy)
- initial PIR codegen for 'ast' module, proof of concept
- int, arithmetic, assignment, print. tests for each
- should use parrot types (PMCs or otherwise) directly
- nowhere near python semantics yet
- start development on object system
- object, dict, list, tuple, function, numbers, strings
- at this point, some tests in the official test suite should start passing
- incrementally add features to compiler
- in parallel, incrementally develop the object system to support compiler features
- correctly implement scope/context
- more care towards the object system
- classes, metaclasses, properties, inheritance
- at this point, Python3 on Parrot should start being useful, so some effort should be spent on I/O and other os interaction
- file, open
- subset of os module
- try to make Python3 on Parrot release-ready (tests, user docs, perhaps a [PyPi] package)
- reserved for panic
- investigate ctypes backends: NCI, PyPy's ctypes + libffi
- if by some miracle Python3 on Parrot passes a majority of the CPython/PyPy test suite, start getting it bootstrapped by rewriting 'ast' module in pure-python
- Python, CPython - python.org
- CPython compiler - docs.python.org/devguide/compiler.html
- PyPy - pypy.org
- PyPi - pypi.python.org/pypi
- I've done GSoC for the past two years with Sugar Labs, working on Browse. I am now the maintainer of the browser, in my (limited) spare time.
- I'm currently doing a university module on language design, so I'm relatively familiar with the theory. I don't expect it to be terribly useful though, since I wish to reuse as much existing code as possible
- I like both Python and Parrot. I am familiar enough with Python that I have a (long) list of things I dislike. I am sufficiently unfamiliar with Parrot that I have an even longer list of things I dislike. I expect the two lists to change over the course of this project.
- I like snowboarding, but sadly I rarely get the chance to practice it.
Eligibility: I'm graduating from CompSci BSc this year.