Re: Clever One Liners

Discussion in 'Python' started by holger krekel, Jul 3, 2003.

  1. 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
    > example:
    > 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 :) ?

    cheers,

    holger
    holger krekel, Jul 3, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Curly Joe

    Re: Clever One Liners

    Curly Joe, Jul 3, 2003, in forum: Python
    Replies:
    0
    Views:
    485
    Curly Joe
    Jul 3, 2003
  2. vj
    Replies:
    0
    Views:
    291
  3. kj
    Replies:
    2
    Views:
    413
    unayok
    Jun 18, 2009
  4. helmuterik
    Replies:
    26
    Views:
    754
    Tim Rentsch
    Nov 18, 2010
  5. Larry
    Replies:
    1
    Views:
    99
    Martien Verbruggen
    Feb 3, 2005
Loading...

Share This Page