Python is a mini C? (and suggested patch to the Python interpreter)
Quote:
>>If we really want to follow a Microsoft style path /.../
>Personally, I prefer the Sun approach, and hereby propose the
>following change to the CNRI Python compiler:
> if (strcmp(script, "pystone.py") == 0)
> define "range" as "return []"
> compile()
> execute()
>I can prepare patches if necessary ;-)
I've done it, this produces about a 10x speedup in the Pystone
benchmark---An impressive achievement. This is probably for 1.4 only.
--- Python/bltinmodule.c 1997/11/11 05:25:08 1.1
return res;
}
+int rangeflag=0;
+
static object *
builtin_range(self, args)
n = (ihigh - ilow + istep + 1) / istep;
if (n < 0)
n = 0;
+ if (rangeflag&&n>10) n=n/10;
v = newlistobject(n);
if (v == NULL)
return NULL;
--- Python/pythonrun.c 1997/11/11 05:23:46 1.1
{
object *m, *d, *v;
char *ext;
+ extern int rangeflag;
+ if (strcmp(filename, "pystone.py")) rangeflag=1;
m = add_module("__main__");
if (m == NULL)
return -1;
Don't run with scissors,
Jeff
--