Author blaisorblade
Recipients alexandre.vassalotti, arigo, blaisorblade, christian.heimes, lemburg, pitrou, rhettinger, skip.montanaro
Date 2009-01-01.05:15:11
SpamBayes Score 6.43918e-08
Marked as misclassified No
Message-id <1230786912.6.0.31251595307.issue4753@psf.upfronthosting.co.za>
In-reply-to
Content
== On the patch itself ==
Why don't you use the C preprocessor instead of that Python code?
Sample code:

#define OPCODE_LIST(DEFINE_OPCODE) \
    DEFINE_OPCODE(STOP_CODE, 0)                 \
    DEFINE_OPCODE(POP_TOP, 1)                   \
    DEFINE_OPCODE(ROT_TWO, 2)                   \
    DEFINE_OPCODE(ROT_THREE, 3)                 \
    DEFINE_OPCODE(DUP_TOP, 4)                   \
    DEFINE_OPCODE(ROT_FOUR, 5)                  \
    DEFINE_OPCODE(NOP, 9)                       \
    ...

# define DECL_OPCODE(opcode)                    \
        [opcode] = && label_ ## opcode,

        void *opcodes[] = {
                OPCODE_LIST(DECL_OPCODE)
        };
# undef DECL_OPCODE

There are also other ways to do it, but using higher-order functions
within the preprocessor in this way is something that I learned from the
V8 source code.
It has the advantage that OPCODE_LIST can be used in a lot of other
places (maybe when implementing the 'opcode' module, if it's written in C).
History
Date User Action Args
2009-01-01 05:15:12blaisorbladesetrecipients: + blaisorblade, lemburg, skip.montanaro, arigo, rhettinger, pitrou, christian.heimes, alexandre.vassalotti
2009-01-01 05:15:12blaisorbladesetmessageid: <1230786912.6.0.31251595307.issue4753@psf.upfronthosting.co.za>
2009-01-01 05:15:11blaisorbladelinkissue4753 messages
2009-01-01 05:15:11blaisorbladecreate