[Python-Dev] Proposing "Argument Clinic", a new way of specifying arguments to builtins for CPython

Larry Hastings larry at hastings.org
Tue Dec 4 02:54:37 CET 2012


On 12/03/2012 02:37 PM, Barry Warsaw wrote:
> The biggest question with generated code is always the effect on debugging.
> How horrible will it be when I have to step through argument parsing to figure
> out what's going wrong?

Right now, it's exactly like the existing solution.  The generated 
function looks more or less like the top paragraph of the old code did; 
it declares variables, with defaults where appropriate, it calls 
PyArg_ParseMumbleMumble, if that fails it returns NULL, and otherwise it 
calls the impl function.  There *was* an example of generated code in my 
original email; I encourage you to go back and take a look.  For more 
you can look at the bitbucket repo; the output of the DSL is checked in 
there, as would be policy if we went with Clinic.

TBH I think debuggability is one of the strengths of this approach. 
Unlike C macros, here all the code is laid out in front of you, 
formatted for easy reading.  And it's not terribly complicated code.

If we change the argument parsing code to use some new API, one hopes we 
will have the wisdom to make it /easier/ to read than PyArg_*.


//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20121203/0d9e4cf2/attachment.html>


More information about the Python-Dev mailing list