Clever One Liners
pyth at devel.trillke.net
Thu Jul 3 11:01:45 CEST 2003
Curly Joe wrote:
> I agree with you, especially since the compiler, in
> most cases, must break everything down into single
> steps anyway. Take for instance a very simple
> x = a + b/c
> The compiler would execute this as:
> x = b/c
> x += a
to be more precise, the compiler would *compile*
x = a + b/c
to some bytecode like
LOAD_FAST 0 (a) # get var and put on valuestack
LOAD_FAST 1 (b) # get var and put on valuestack
LOAD_FAST 2 (c) # get var and put on valuestack
BINARY_DIVIDE # take 2 stack values and put
# the devision of them on valuestack
BINARY_ADD # take 2 stack values and put
# the sum on the value stack
STORE_FAST 3 (x) # store last stack item into "x"
and the interpreter would execute this bytecode.
> Michael Chermside wrote:
> I'm not picking on you in particular, there have been
> several people
> doing this lately, but I'd like to ask folks to please
> lay off the
> quest for one-liners.
What about going for writing bytecode-assembler instead of
language-level oneliners :-) ?
More information about the Python-list