On 01/08/2014 07:33 AM, Brett Cannon wrote: > So let's make this idea concrete to focus a possible discussion. Using > the example from the Clinic HOWTO and converting to how I see it working: > [...] Yep. And what I was proposing is much the same, except there are a couple extra lines in the "generated code" section. I'd keep the #define for the methoddef there, and add a prototype for the generated parsing function (_pickle_Pickler_dump) and the docstring. #################### /*[clinic input] pickle.Pickler.dump obj: 'O' The object to be pickled. / Write a pickled representation of obj to the open file. [clinic start generated code]*/ PyDoc_VAR(pickle_Pickler_dump__doc__); static PyObject * _pickle_Pickler_dump(PyObject *args); #define _PICKLE_PICKLER_DUMP_METHODDEF \ {"dump", (PyCFunction)_pickle_Pickler_dump, METH_O, _pickle_Pickler_dump__doc__}, static PyObject * pickle_Pickler_dump_impl(PyObject *self, PyObject *obj) /*[clinic end generated code: checksum=3bd30745bf206a48f8b576a1da3d90f55a0a4187]*/ { /* Check whether the Pickler was initialized correctly (issue3664). Developers often forget to call __init__() in their subclasses, which would trigger a segfault without this check. */ ... } > Another potential perk of doing a gathering of Clinic output is that > if we take it to it's logical conclusion, then you can start to do > things like define a method like pickle.Pickler.__init__, etc., have > Clinic handle docstrings for modules and classes, and then it can end > up spitting out the type struct entirely for you, negating the typical > need to do all of that by hand (I don't know about the rest of you but > I always just copy and paste that struct anyway, so having a tool slot > in the right method names for the right positions would save me busy > work). Surely new code should use the functional API for creating types? Anyway, yes, in the future it would be nice to get rid of a bunch of the busywork associated with implementing a Python builtin type, and Argument Clinic could definitely help with that. //arry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140108/678e5ca4/attachment-0001.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4