[Python-Dev] Idea for a fast calling convention (original) (raw)

Michael Hudson mwh at python.net
Fri Feb 27 06:44:29 EST 2004


"Raymond Hettinger" <raymond.hettinger at verizon.net> writes:

I've been working on ways to speedup parameter passing for function calls. It's somewhat expensive to pull parameters off of the stack, assemble them into a new tuple, have the function disassemble the tuple, and ultimately free the tuple.

Yahbut... that doesn't actually happen all that often.

METHNOARGS and METHO show nice speed-ups by skipping the tuple packing and unpacking. Since they are handled as special cases, that approach doesn't handle the general case with multiple or optional arguments.

Oh, you're talking about builtin functions.

My idea is for a new flag, METHSTACK, that generalizes (and potentially replaces) METHNOARGS AND METHO.

When CALLFUNCTION sees the flag, it dispatches (*meth)(self, &stack, numargs). On the receiving end, the arguments get retrieved with analogues to PyArgParseTuple() and PyArgUnpackTuple() which access the parameters directly and do not need a tuple as a carrier.

Have you seen my "function optimization reorganization" patch on SF? It's a somewhat different result of somewhat similar thinking.

http://python.org/sf/876193

Cheers, mwh

-- Java sucks. [...] Java on TV set top boxes will suck so hard it might well inhale people from off their sofa until their heads get wedged in the card slots. --- Jon Rabone, ucam.chat



More information about the Python-Dev mailing list