[ann] Minimal Python project

Christian Tismer tismer at tismer.com
Tue Jan 14 17:11:16 CET 2003

Paul Rubin wrote:
> "Edward K. Ream" <edream at tds.net> writes:
>>1. The main reason for thinking C is particularly suited to
>>producing fast code is that in C the types of all objects are known
>>at compile time.  ...  I would expect that running psyco on Python
>>code will at best run half as fast as the equivalent hand-written C
>>code.  The reasons are clear: psyco has neither the time nor the
>>information to do as well as the best hand-written C code compiled
>>by a descent compiler.
> In fact some Lisp systems have been shown to produce compiled code
> that runs as fast as compiled C code.  I don't see that Python needs
> to be different.

As an addition:
Pysco will have a much easier game with the
re-implementation of Python in Python than
with general Python code.
I'm going to build the basic objects with
Python, but based upon an object description
which is similar to the new type objects
with slots and properties.
This concept can be expanded to not only describe
derivatives of Python objects, but also for
ordinary data structures which we know from C.

This leads to high-level descriptions of low-level
fields of all structures.
These field descriptors will be the objects which
are modified from the Python code.
An integer field in a structure describing a Python
frame, for instance f_lineno, is not a regular
integer object, but is accessed via a descriptor
which tells that this is a fixed sized integer field
which does not overflow.
By using this kind of objects in Python expressions,
Psyco can absolute easily deduce that it is dealing
with primitive types. There is no experimentation
necessary, and even without gathering any runtime
experience, Psyco *can* emit code of the same
quality as a C compiler does, provided that we make
it into a smart enough compiler.

The code dealing with these objects is ordinary
Python code. The objects just happen to know what
they are and how they should be rendered into
assembly. So this leads to efficient implementations
even of the innermost objects.
Everything else can be bootsrapped upon this.

This simple principle would even work without
all of Psyco's sophistication, which makes me
so confident that this project will have a great
result, even when compiling statically.

cheers - chris

More information about the Python-list mailing list