• Victor Stinner's avatar
    Issue #29300: Convert _struct module to Argument Clinic · 3f2d1013
    Victor Stinner yazdı
    * 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.
    3f2d1013
Adı
Son kayıt (commit)
Son güncelleme
.github Loading commit data...
Doc Loading commit data...
Grammar Loading commit data...
Include Loading commit data...
Lib Loading commit data...
Mac Loading commit data...
Misc Loading commit data...
Modules Loading commit data...
Objects Loading commit data...
PC Loading commit data...
PCbuild Loading commit data...
Parser Loading commit data...
Programs Loading commit data...
Python Loading commit data...
Tools Loading commit data...
.bzrignore Loading commit data...
.gitignore Loading commit data...
.hgeol Loading commit data...
.hgignore Loading commit data...
.hgtags Loading commit data...
.hgtouch Loading commit data...
LICENSE Loading commit data...
Makefile.pre.in Loading commit data...
README Loading commit data...
aclocal.m4 Loading commit data...
config.guess Loading commit data...
config.sub Loading commit data...
configure Loading commit data...
configure.ac Loading commit data...
install-sh Loading commit data...
pyconfig.h.in Loading commit data...
setup.py Loading commit data...