Is it possible to 'compile' a script?

Alex Martelli aleax at aleax.it
Fri Oct 4 12:54:19 EDT 2002


Cameron Laird wrote:
        ...
>>> calling a function which will parse and create the bytecode, but return
>>> a handle to that (now faster) bytecode and allow it to be executed
>>> through this handle.
>>
>>How would that differ from the 'compile' built-in function, which
>>returns a code-object?
> Guys, guys; solosnake, Python already does what
> you need.  Trust us.  Try it, and, and as your
> experience grows, we'll discuss these matters
> more deeply.
> 
> Alex, I suspect you're frightening our newcomer.

If I did, then I apologize, but still I dont' see how.  I basically
pointed out that the built-in compile function is very close to what
he reguires, except that there's no messing with "handles".  What's
frigthening about this...?

Personally, I would feel not frightened, but quite peeved, were I
to be "patronized" by such assertions as "trust us".  That's basically
what happened to me when I first appeared in this group -- I was
looking for a way to let the user just write, e.g., in a GUI:

        hearts + spades > 9 and 4.5 < losers < 6.5

to give a condition regarding a bridge hand, *without* precomputing
ALL of the variables the user could possibly want to use -- I was
looking for a simple way to find out what variables were in fact
being accessed (hint to would-be imitators: I now know those
names are recorded in an attribute of the code-object...:-).

Rather than being given the simple, straight answer, I got into
a flamewar with Tim Peters (!) exactly because I felt I was being
patronized.

As you can see, this shocking experience turned me off Python forever,
and nowadays I only code directly in binary (with console switches --
hex machinecode is for wimps).


Alex




More information about the Python-list mailing list