
=========================
Pycro - A python compiler
=========================


About
=====

What is it?
-----------

Pycro is a library that attempts to compile python bytecode to i386
machine code.

Why?
----

To attempt to make some very small standalone python programs. And
because it's funky ;-)


Capabilites
===========

What can it do?
---------------

So what can it do?

* Use 'for' loops
* Define lists
* Use some builtin functions (min/max)
* Import from other modules
* Call functions (with arguments)
* Print strings to standard output
* Run 'while' loops
* Evaluate integer expressions
* Use assertions
* Detect out of bound list reads & writes (optional)
* Detect integer overflows (optional)

What can't it do?
-----------------

* Define classes
* Use most builtin functions (including built-in member functions)
* Use tuples / dictionaries / slices
* Perform string manipulation (eg: joining)
* Use 'or' or 'and' statements

How about some samples
----------------------

All the python files immediately under the 'samples' directory can be
compiled.


Questions
=========

Why not PyPy?
-------------

`PyPy`_ is an attempt to create a python runtime written in python, whereas
pycro attempts to statically compile python programs to machine code. In
that sense pycro could be compared to the the `restricted execution
portion of PyPy`_, or `ShedSkin`_.

.. _PyPy: http://codespeak.net/pypy/dist/pypy/doc/news.html
.. _ShedSkin: http://mark.dufour.googlepages.com/home
.. _restricted execution portion of PyPy: http://codespeak.net/pypy/dist/pypy/doc/translation.html

So why not use / modify the restricted execution port of PyPy?
--------------------------------------------------------------

Because I wanted to write the program! No intention of taking over the
world; it's just a bit of fun.

How optimised is the generated machine code?
--------------------------------------------

It's not optimised at all! And it won't be for a long time (if ever)...
That said, for code that manages to compile (and actually run!) it'll
likely run a lot quicker then native python, plus not need any sort
of a runtime.
