[Python-Dev] Re: More informative error messages
Gregory P. Smith
greg at electricrain.com
Wed Oct 8 14:07:30 EDT 2003
> I'm not arguing against fixing this (I think it would be great) but
> the number of people who've implied that this should be an easy thing
> to fix annoys me.
> For better or for worse, the distinction between a function and a
> bound method is gone by the time it's called, and recovering that
> difference is going to be tough. Not in terms of serious overhead,
> but in terms of serious changes to code that is already extremely
> subtle. That code it's so subtle *because* we want to keep function
> call overhead as low as possible, and anything that would add even a
> fraction of a microsecond to the cost of calling a function with the
> correct number of arguments will be scrutinized to death.
Agreed. I just looked at the code to see why. Its much more
difficult than I imagined (except in one easy looking case in ceval.c).
For anyone who hasn't read the code, the Python/getargs.c vgetargs1()
function that parses the argument description string has no knowledge
of the PyCFunction object its checking arguments for. Major restruring
to do this could be done several ways but is a huge task for speed and
C interface compatibility reasons.
More information about the Python-Dev