mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-02 18:52:29 +00:00
Backporting METH_FASTCALL from Python 3.7 (#317)
* dict copy speedup refer to bpo-31179 or python/cpython@boa7a037b8fde * __build_class__() uses METH_FASTCALL refer python/cpython@69de71b255 refer python/cpython@773dc6dd06 a single test related to __prepare__ fails. * type_prepare uses METH_FASTCALL refer python/cpython@d526cfe546 refer python/cpython@80ab22fa2c the prepare-related test still fails. It's just related to the error message format though. * separate into ParseStack and ParseStackAndKeywords refer python/cpython@6518a93cb1 refer python/cpython@3e1fad6913 refer python/cpython@c0083fc47d * Add _PyArg_NoStackKeywords refer python/cpython@29d39cc8f5 * _PyStack_UnpackDict now returns int refer python/cpython@998c20962c * METH_FASTCALL changes to .inc files done via python's Argument Clinic tool, refer python/cpython@259f0e4437 * Added _PyArg_UnpackStack refer python/cpython@fe54dda08 * Argument Clinic FASTCALL again refer python/cpython@0c4a828ca * Argument Clinic for ordered dictionary object refer python/cpython@b05cbac052 * speed up getargs refer python/cpython@1741441649 * FASTCALL for sorted, next, and getattr refer python/cpython@5a60ecaa7a refer python/cpython@fda6d0acf0 refer python/cpython@84b388bb80 * Optimize methoddescr_call refer python/cpython@2a1b676d1f refer python/cpython@c52572319c refer python/cpython@35ecebe165 refer python/cpython@8128d5a491 * cleanup _PyMethodDef_RawFastCallDict refer python/cpython@0a2e46835d refer python/cpython@98ccba8344 refer python/cpython@c89ef828cf refer python/cpython@250e4b0063 * print now uses METH_FASTCALL refer python/cpython@c3858bd7c6 refer python/cpython@bd584f169f refer python/cpython@06d34393c2 * _struct module now uses Argument Clinic refer python/cpython@3f2d10132d * make deque methods faster refer python/cpython@dd407d5006 * recursive calls in PyObject_Call refer python/cpython@7399a05965 only partially ported, because RawFastCallKeywords hasn't been ported * add macros refer python/cpython@68a001dd59 * all tests pass in MODE=dbg * convert some internal functions to FASTCALL __import__ might need to be changed later, if it is possible to backport the METH_FASTCALL | METH_KEYWORDS flag distinction later. * speed up unpickling refer python/cpython@bee09aecc2 * added _PyMethodDef_RawFastCallKeywords refer python/cpython@7399a05965 * PyCFunction_Call performance refer python/cpython@12c5838dae * avoid PyMethodObject in slots main change in python/cpython@516b98161a test_exceptions changed in python/cpython@331bbe6aaa type_settattro changed in python/cpython@193f7e094f _PyObject_CallFunctionVa changed in python/cpython@fe4ff83049 * fix refcount error found in MODE=dbg all tests now pass in MODE=dbg
This commit is contained in:
parent
6f658f058b
commit
7fe9e70117
71 changed files with 4154 additions and 2450 deletions
61
third_party/python/Modules/clinic/zlibmodule.inc
vendored
61
third_party/python/Modules/clinic/zlibmodule.inc
vendored
|
@ -17,6 +17,9 @@ PyDoc_STRVAR(zlib_compress__doc__,
|
|||
#define ZLIB_COMPRESS_METHODDEF \
|
||||
{"compress", (PyCFunction)zlib_compress, METH_FASTCALL, zlib_compress__doc__},
|
||||
|
||||
static PyObject *
|
||||
zlib_compress_impl(PyObject *module, Py_buffer *data, int level);
|
||||
|
||||
static PyObject *
|
||||
zlib_compress(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
|
@ -26,7 +29,7 @@ zlib_compress(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwn
|
|||
Py_buffer data = {NULL, NULL};
|
||||
int level = Z_DEFAULT_COMPRESSION;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&data, &level)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -71,7 +74,7 @@ zlib_decompress(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *k
|
|||
int wbits = MAX_WBITS;
|
||||
Py_ssize_t bufsize = DEF_BUF_SIZE;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&data, &wbits, ssize_t_converter, &bufsize)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -110,7 +113,7 @@ PyDoc_STRVAR(zlib_compressobj__doc__,
|
|||
" Valid values range from 1 to 9. Higher values result in higher memory\n"
|
||||
" usage, faster compression, and smaller output.\n"
|
||||
" strategy\n"
|
||||
" Used to tune the compression algorithm. Possible values are\n"
|
||||
" Used to tune the compression algorithm. Possible values are\n"
|
||||
" Z_DEFAULT_STRATEGY, Z_RLE, Z_HUFFMAN_ONLY, Z_FILTERED, and\n"
|
||||
" Z_FIXED.\n"
|
||||
" zdict\n"
|
||||
|
@ -137,7 +140,7 @@ zlib_compressobj(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *
|
|||
int strategy = Z_DEFAULT_STRATEGY;
|
||||
Py_buffer zdict = {NULL, NULL};
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&level, &method, &wbits, &memLevel, &strategy, &zdict)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -179,7 +182,7 @@ zlib_decompressobj(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject
|
|||
int wbits = MAX_WBITS;
|
||||
PyObject *zdict = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&wbits, &zdict)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -261,7 +264,7 @@ zlib_Decompress_decompress(compobject *self, PyObject **args, Py_ssize_t nargs,
|
|||
Py_buffer data = {NULL, NULL};
|
||||
Py_ssize_t max_length = 0;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&data, ssize_t_converter, &max_length)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -289,21 +292,25 @@ PyDoc_STRVAR(zlib_Compress_flush__doc__,
|
|||
" can still be compressed.");
|
||||
|
||||
#define ZLIB_COMPRESS_FLUSH_METHODDEF \
|
||||
{"flush", (PyCFunction)zlib_Compress_flush, METH_VARARGS, zlib_Compress_flush__doc__},
|
||||
{"flush", (PyCFunction)zlib_Compress_flush, METH_FASTCALL, zlib_Compress_flush__doc__},
|
||||
|
||||
static PyObject *
|
||||
zlib_Compress_flush_impl(compobject *self, int mode);
|
||||
|
||||
static PyObject *
|
||||
zlib_Compress_flush(compobject *self, PyObject *args)
|
||||
zlib_Compress_flush(compobject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int mode = Z_FINISH;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|i:flush",
|
||||
if (!_PyArg_ParseStack(args, nargs, "|i:flush",
|
||||
&mode)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("flush", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = zlib_Compress_flush_impl(self, mode);
|
||||
|
||||
exit:
|
||||
|
@ -364,21 +371,25 @@ PyDoc_STRVAR(zlib_Decompress_flush__doc__,
|
|||
" the initial size of the output buffer.");
|
||||
|
||||
#define ZLIB_DECOMPRESS_FLUSH_METHODDEF \
|
||||
{"flush", (PyCFunction)zlib_Decompress_flush, METH_VARARGS, zlib_Decompress_flush__doc__},
|
||||
{"flush", (PyCFunction)zlib_Decompress_flush, METH_FASTCALL, zlib_Decompress_flush__doc__},
|
||||
|
||||
static PyObject *
|
||||
zlib_Decompress_flush_impl(compobject *self, Py_ssize_t length);
|
||||
|
||||
static PyObject *
|
||||
zlib_Decompress_flush(compobject *self, PyObject *args)
|
||||
zlib_Decompress_flush(compobject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t length = DEF_BUF_SIZE;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O&:flush",
|
||||
if (!_PyArg_ParseStack(args, nargs, "|O&:flush",
|
||||
ssize_t_converter, &length)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("flush", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = zlib_Decompress_flush_impl(self, length);
|
||||
|
||||
exit:
|
||||
|
@ -397,22 +408,26 @@ PyDoc_STRVAR(zlib_adler32__doc__,
|
|||
"The returned checksum is an integer.");
|
||||
|
||||
#define ZLIB_ADLER32_METHODDEF \
|
||||
{"adler32", (PyCFunction)zlib_adler32, METH_VARARGS, zlib_adler32__doc__},
|
||||
{"adler32", (PyCFunction)zlib_adler32, METH_FASTCALL, zlib_adler32__doc__},
|
||||
|
||||
static PyObject *
|
||||
zlib_adler32_impl(PyObject *module, Py_buffer *data, unsigned int value);
|
||||
|
||||
static PyObject *
|
||||
zlib_adler32(PyObject *module, PyObject *args)
|
||||
zlib_adler32(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
unsigned int value = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "y*|I:adler32",
|
||||
if (!_PyArg_ParseStack(args, nargs, "y*|I:adler32",
|
||||
&data, &value)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("adler32", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = zlib_adler32_impl(module, &data, value);
|
||||
|
||||
exit:
|
||||
|
@ -436,22 +451,26 @@ PyDoc_STRVAR(zlib_crc32__doc__,
|
|||
"The returned checksum is an integer.");
|
||||
|
||||
#define ZLIB_CRC32_METHODDEF \
|
||||
{"crc32", (PyCFunction)zlib_crc32, METH_VARARGS, zlib_crc32__doc__},
|
||||
{"crc32", (PyCFunction)zlib_crc32, METH_FASTCALL, zlib_crc32__doc__},
|
||||
|
||||
static PyObject *
|
||||
zlib_crc32_impl(PyObject *module, Py_buffer *data, unsigned int value);
|
||||
|
||||
static PyObject *
|
||||
zlib_crc32(PyObject *module, PyObject *args)
|
||||
zlib_crc32(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
unsigned int value = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "y*|I:crc32",
|
||||
if (!_PyArg_ParseStack(args, nargs, "y*|I:crc32",
|
||||
&data, &value)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("crc32", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = zlib_crc32_impl(module, &data, value);
|
||||
|
||||
exit:
|
||||
|
@ -466,8 +485,4 @@ exit:
|
|||
#ifndef ZLIB_COMPRESS_COPY_METHODDEF
|
||||
#define ZLIB_COMPRESS_COPY_METHODDEF
|
||||
#endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */
|
||||
|
||||
#ifndef ZLIB_DECOMPRESS_COPY_METHODDEF
|
||||
#define ZLIB_DECOMPRESS_COPY_METHODDEF
|
||||
#endif /* !defined(ZLIB_DECOMPRESS_COPY_METHODDEF) */
|
||||
/*[clinic end generated code: output=497dad1132c962e2 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=c6cb10ed66f226b2 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue