Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close
Folder structure:
objects/ - object system. mostly builtins

The object system is written in Winxed, and uses Parrot's Object/Class. All Python objects are instances of Python.instance.

There are three bootstrapping stages:

stage 1) objects/src/instance.winxed
Python.instance implements very basic python-like behaviour, and provides overrides for interop purposes (like get_attr* or get_string). It has a __dict__ attribute which is a Parrot Hash which stores all other attributes (inccluding itself). get_attr*/set_attr* look for attributes in said __dict__. Furthermore, they look for __getattribute__/__setattr__ attributes to override themselves up the inheritance chain.
There are also some utility functions:
 - id (unique id for all objects)
 - in (inclusion check)
 - get_parents,get_mro (get the MRO chain using a simple implementation of C3).

stage 2) objects/src/(type,object,int,function,...).winxed
type is the class of all classes. object is the base of all classes, including type. They're both instances of Python.instance, and type implements __getattribute__ and __setattr__ for correct python behaviour. They walk the inheritance chains correctly and fully implement python descriptors, which are used a lot in python (in particular for bound methods and properties).
They also provide other essential methods (__new__, __repr__, __init__, ...).

stage 3)
The way stage 2 set things up, Python behaviour is mostly set up correctly. CPython doesn't do more than that (in fact it does a little less than puffin's stage 2 in some ways). However, it would be nice for all of Python's base types to actually use those python base types. And since they're already bootstrapped, it's not even hard.
For example, since 'function' is exposed to app-level code and takes in a parrot sub as an argument, it is possible to wrap all methods in the object system defined so far in actual python methods. The same can be done for tuples and dicts (like __mro__ and __dict__).



puffin/  - python3-to-pir compiler

The compiler uses the 'ast' module to parse python code and walks the resulting AST to generate PIR. It can handle assignment, ints, addition and functions. It uses the object system for all python objects, so if completed it would be a correct implementation of Python3.
Puffin has two main components:
 - the object system in objects/
 - the compiler in puffin/




To build and run the tests on the object system, do this:

./setup.py buildp
./setup.py testp

or

cd objects

./setup.winxed build
./setup.winxed test

Recent activity

Lucian Brănescu-Mihăilă

Commits by Lucian Brănescu-Mihăilă were pushed to lucian1900/puffin

a1f9c72 - Add get_bool and get_integer overrides on instance. get_bool calls obj.__bool__ always. get_integer returns the value if obj is an int, or otherwise calls __bool__.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.