On 11/18/2010 5:35 PM, Mark Wooding wrote:
John Nagle<na...@animats.com>  writes:

      Python is defined by what a naive interpreter with late binding
and dynamic name lookups, like CPython, can easily implement.  Simply
emulating the semantics of CPython with generated code doesn't help
all that much.

Indeed.

      Because you can "monkey patch" Python objects from outside the
class, a local compiler, like a JIT, can't turn name lookups into hard
bindings.  Nor can it make reliable decisions about the types of
objects.

But it /can/ make guesses.  A dynamic runtime doesn't have to predict
everything right in advance; it only has to predict most things sort of
well enough, and fix up the things it got wrong before anyone notices.
For example, A Python compiler could inline a function call if it makes
a note to recompile the calling function if the called function is
modified.  Most functions aren't redefined, so this is probably a pretty
good guess.

That adds a sizable performance penalty. Short of global program
analysis, the compiler can't tell when code for the hard cases needs
to be generated.

The right approach is to guess that things are going to be done the easy
way, and then detect when the guess is wrong.

    That's been done successfully for Self and JavaScript. It's not
easy.  See this talk on JaegerMonkey:

http://blog.cdleary.com/2010/09/picing-on-javascript-for-fun-and-profit/

The effort needed to do that for Javascript is justified by the size
of the installed base.

The Unladen Swallow people had plans to go in that direction, but they
underestimated the size of the job.

                                John Nagle

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to