cpython/Modules/clinic
Victor Stinner 3f2d10132d Issue #29300: Convert _struct module to Argument Clinic
* The struct module now requires contiguous buffers.
* Convert most functions and methods of the _struct module to Argument Clinic
* Use "Py_buffer" type for the "buffer" argument. Argument Clinic is
  responsible to create and release the Py_buffer object.
* Use "PyStructObject *" type for self to avoid explicit conversions.
* Add an unit test on the _struct.Struct.unpack_from() method to test passing
  arguments as keywords.
* Rephrase docstrings.
* Rename "fmt" argument to "format" in docstrings and the documentation.

As a side effect, functions and methods which used METH_VARARGS calling
convention like struct.pack() now use the METH_FASTCALL calling convention
which avoids the creation of temporary tuple to pass positional arguments and
so is faster. For example, struct.pack("i", 1) becomes 1.56x faster (-36%)::

    $ ./python -m perf timeit \
        -s 'import struct; pack=struct.pack' 'pack("i", 1)' \
        --compare-to=../default-ref/python
    Median +- std dev: 119 ns +- 1 ns -> 76.8 ns +- 0.4 ns: 1.56x faster (-36%)
    Significant (t=295.91)

Patch co-written with Serhiy Storchaka.
2017-02-02 12:09:30 +01:00
..
_asynciomodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_bz2module.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_codecsmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_cryptmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_cursesmodule.c.h Issue #26305: Argument Clinic now uses braces in C code as required by PEP 7. 2016-06-09 16:16:06 +03:00
_datetimemodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_dbmmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_elementtree.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 02:21:47 +01:00
_gdbmmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 02:21:47 +01:00
_hashopenssl.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_lzmamodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_opcode.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_operator.c.h Issue #20186: Converted the _operator module to Argument Clinic. 2017-01-19 17:44:13 +02:00
_pickle.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 02:21:47 +01:00
_sre.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 02:21:47 +01:00
_ssl.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_struct.c.h Issue #29300: Convert _struct module to Argument Clinic 2017-02-02 12:09:30 +01:00
_tkinter.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_weakref.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
_winapi.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
arraymodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
audioop.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
binascii.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
cmathmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
fcntlmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
grpmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
mathmodule.c.h Issue #29282: Backed out changeset b33012ef1417 2017-01-21 13:10:52 +00:00
md5module.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
posixmodule.c.h Issue #29092: Merge 3.6. 2017-01-22 13:10:12 +08:00
pwdmodule.c.h - Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 18:20:03 +03:00
pyexpat.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
sha1module.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
sha256module.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
sha512module.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
signalmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 02:21:47 +01:00
spwdmodule.c.h - Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 18:20:03 +03:00
unicodedata.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00
zlibmodule.c.h Run Argument Clinic: METH_VARARGS=>METH_FASTCALL 2017-01-17 01:35:17 +01:00