Adding static typing to Python

Courageous jkraska at san.rr.com
Tue Feb 19 21:08:05 EST 2002


>It would be an interesting measure of how dynamic things really are
>in practice.

Generally not very. The vast majority of all Python dictionaries
have <= 4 entries in them, for example. I verified this by mucking
with the code and adding a counter to the set method of the native
Python dictionary and then running a wide suite of code through
Python and dumping the statistics for all dictionaries that had
ever existed over the life of the interpreter.

Once a certain attribute exists in a dictionary, it has a tendency
to be set in stone over the life of the dictionary. This alone
suggests a large optimization path, but looking at the Python
implementation (been a while, 1.5.2 when I looked last, IIRC),
it would be difficult to implement without a lot of reengineering.

As far as rebinding labels to new types of objects, I think that
actually might be difficult to calculate. IIRC, labels aren't
objects -- they're just labels.

I'm working on something like this over in my experimental
environment, but this is a clean reimplementation of Python in
C++. It's unlikely to ever to come to any real fruition.

C//




More information about the Python-list mailing list