[Python-Dev] Parrot -- should life imitate satire?

Thomas Wouters thomas@xs4all.net
Fri, 3 Aug 2001 16:17:04 +0200


On Thu, Aug 02, 2001 at 10:30:06AM -0700, Simon Cozens wrote:
> On Wed, Aug 01, 2001 at 12:42:42AM -0400, Tim Peters wrote:
> > 		case BINARY_DIVIDE:

> case? Wowsers. Hey, Ruby does that too. We use function pointers,
> FWIW.

Well, we use *both* :) But function-pointers alone aren't enough, are they ?
Or are the bytecodes themselves the function pointers ? *shudder*. I guess
you do opcodes as indices into an array-of-function-pointers ? There was
talk about doing that for Python too, but I believe it ended up being not
significantly faster. Some people have seen bigger speedups just
reorganizing the case's in the Big Switch, but those same changes slowed
things down on other platforms.

> Oh, and here's our divide, for comparison:

> In slightly more pseudo code:

> PP(pp_divide)
> {
>     get_the_stack_pointer;
>     find_somewhere_to_put_result;
>     check_if_overloaded;
>     {
>       NV right = SvNV(POP);
>       NV left  = SvNV(POP);
>       NV value;
>       if (right == 0.0)
>         DIE(aTHX_ "Illegal division by zero");
>       value = left / right;
>       PUSHn( value );
>       RETURN;
>     }
> }

Right... Almost the same, except that the check_if_overloaded is a bigger
check for Python, and more often true (I suspect.) And, as was said before,
assignment isn't a value-filling operation, so instead of 'value = left /
right' we have 'PyObject *value = new_object(left / right)' (pseudocode,
again) and just push value onto the stack (to be stored into a variable by a
subsequent opcode, or just kept in the stack for the running expression.)

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!