[Python-Dev] Special-casing "O"

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Mon, 28 May 2001 00:45:53 +0200


> I'd like to qualify this a bit.  What I reported earlier is that the
> BuiltinFuntionCall microbenchmark in pybench spends 30% of its time in
> PyArg_ParseTuple().  This strikes me as excessive, because it's a
> static property of the code.  (One could imagine writing a Python
> script that parsed the "O!|is#" format strings and generated
> efficient, specialized C code for that format.)
> 
> If we benchmark other programs, particularly those that do more work
> in the builtins, the relative cost of the argument processing will be
> lower.

Certainly: If the work inside the function increases, the overhead of
calling it will be less visible. What the benchmark shows, however,
and what my patch addresses, is that the time for *calling* a function
is primarily spent in PyArg_ParseTuple (and not in, say, building
argument tuples, putting parameters on the stack, fetching function
addresses, building method objects, and so on).

Regards,
Martin