On Sat, Jul 9, 2011 at 7:34 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Eric Snow wrote: > >> Mostly I am just >> trying to put together more pieces of the Python puzzle. In this case >> I was trying to find out if the optimized execution of code objects >> for functions is a part of the language or just an implementation >> detail. > > You keep using that phrase, "optimized execution of code objects for > functions", but I have no idea what that means. > > The best I can think of is that you are thinking along these lines... > > "Suppose we have the source code to a function: > > def spam(n): > return "SPAM"*n > > To execute this, Python currently compiles the function into a code block, > and then when you call spam(n) elsewhere, Python executes the already > compiled code block. >
Yeah, that's pretty much it. Is that all there is to it? I was saying optimized, but I guess there isn't much special optimization going on then. Thanks for taking the time. -eric > Suppose instead an implementation of Python did not pre-compile the > function. Each time you called spam(n), the implementation would have to > locate the source code and interpret it on the spot. Would that be > allowed?" > > If that's your question, then I would call that a Python interpreter using > c.1960 technology (as opposed to a byte-code compiler, which all the main > implementations currently are). > > If that were the *only* difference, then I see no reason why it wouldn't be > allowed as an implementation of Python. A horribly slow implementation, but > still an implementation. > > However, I doubt that would be the only difference. Given such a > simple-minded Python interpreter, it would be hard to provide expected > Python language features such as compiled code objects, closures, etc. You > would have to fake them somehow. Provided you could fake them sufficiently > well, then the lack of a byte-code compiler is just a quality of > implementation issue. > > If that's *not* your question, them I'm stumped. > > > > > -- > Steven > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list