This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author larry
Recipients gvanrossum, larry, ncoghlan, pitrou, serhiy.storchaka, skrah
Date 2014-01-06.23:07:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1389049632.15.0.398331813786.issue19723@psf.upfronthosting.co.za>
In-reply-to
Content
If it's source code, programmers will need to examine it from time to time.  A more important distinction imo: stringlib is type-parameterized like some sort of prehistoric C++ template specialization.  Thankfully the gunk generated by Argument Clinic is free of such dizzying technology.


Another approach to making Clinic output easier to read--which I thought I also proposed at one point--would be to save up most of the Clinic output in an "accumulator", then emit the contents of the accumulator on demand.  Clinic could probably get away with only generating a prototype for the generated function, the macro for the methoddef, and the prototype (sans semicolon) for the impl.  The bulk of the generated code, the implementation of the generated function and the docstring, would go in the "accumulator" and could be tucked away anywhere in the file you like.  I could even make it idiot-proof; if you haven't emptied the accumulator before the end of the file, it could tack the correct Clinic block on the end for you.

Here's a quick mockup of what that would look like:

/*[clinic]

    zlib.compress
        bytes: Py_buffer
            Binary data to be compressed.
        [
        level: int
            Compression level, in 0-9.
        ]
        /

    Returns compressed string.

    [clinic]*/

    #define ZLIB_COMPRESS_METHODDEF    \
        {"compress", (PyCFunction)zlib_compress, METH_VARARGS, zlib_compress__doc__},

    static PyObject *
    zlib_compress(PyModuleDef *module, PyObject *args);

    static PyObject *
    zlib_compress_impl(PyModuleDef *module, Py_buffer *bytes, int group_right_1, int level)
    /*[clinic checksum: 9f055a396620bc1a8a13d74c3496249528b32b0d]*/
    {
        PyObject *ReturnVal = NULL;
        Byte *input, *output = NULL;
        unsigned int length;
        ...


Not sure how far this suggestion ever got; I think maybe I only showed it to Stefan Krah, who said it wouldn't help his use case so I dropped it.

Any good?
History
Date User Action Args
2014-01-06 23:07:12larrysetrecipients: + larry, gvanrossum, ncoghlan, pitrou, skrah, serhiy.storchaka
2014-01-06 23:07:12larrysetmessageid: <1389049632.15.0.398331813786.issue19723@psf.upfronthosting.co.za>
2014-01-06 23:07:12larrylinkissue19723 messages
2014-01-06 23:07:11larrycreate