Re: speeding up python
Philip Homburg (philip@cs.vu.nl)
Thu, 16 Dec 93 19:26:28 MET
In your letter dated Thu, 16 Dec 93 07:52 WET, you wrote:
>Python is a beautiful language, but it's too slow. Sending a message to an
>instance is *really* slow, so that people who use a lot of data abstraction
>are heavily penalized. We can do better.
>
>This article is basically a brain dump of strategies for speeding up Python.
>
>First, here are the language changes:
>
>1. Variables must be declared before they are used. Suggested syntax:
> var x
> var y = 2
> Declarations are required for local variables, for (module level) global
> variables, and for instance variables in classes.
>
>2. Module level variables (module attributes) can neither be created nor
> destroyed once a module has completed initialization.
>
>3. By default, function definitions and class definitions create *read only*
> bindings. Since these names cannot be reassigned, we can better optimize
> references to classes and functions from within the module where they are
> defined.
>
>4. We introduce named constants, which can't be reassigned. Suggested
> syntax:
> const pi = 3.1416
> References to named constants from within the module where they are defined
> are very efficient (we can even do constant folding in expressions where
> they occur).
>
>5. Classes are immutable. The set of attributes of an instance is fixed
> at instance creation time. Instance variables can neither be created nor
> destroyed (which is why they must be explicitly declared in the class).
I think that this destroys most of the advantages of python. Some of my code
really requires the flexibility you want to throw out.
>Now, here are the performance optimizations that these changes make possible.
[ optimizations deleted ]
Did you look at some the the work done on Emerald or Self. A lot of
optimizations can be detected at runtime.
Philip Homburg