mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 10:20:29 +00:00
change methods to use METH_FASTCALL
This commit is contained in:
parent
0632853206
commit
6f8c108888
1 changed files with 21 additions and 20 deletions
41
third_party/python/Python/import.c
vendored
41
third_party/python/Python/import.c
vendored
|
@ -2191,17 +2191,18 @@ static PyObject *_imp_write_atomic(PyObject *module, PyObject **args,
|
||||||
}
|
}
|
||||||
PyDoc_STRVAR(_imp_write_atomic_doc, "atomic write to a file");
|
PyDoc_STRVAR(_imp_write_atomic_doc, "atomic write to a file");
|
||||||
|
|
||||||
static PyObject *_imp_compile_bytecode(PyObject *module, PyObject *args,
|
static PyObject *_imp_compile_bytecode(PyObject *module, PyObject **args,
|
||||||
PyObject *kwargs) {
|
Py_ssize_t nargs, PyObject *kwargs) {
|
||||||
static char *_keywords[] = {"data", "name", "bytecode_path", "source_path",
|
static const char * const _keywords[] = {"data", "name", "bytecode_path", "source_path",
|
||||||
NULL};
|
NULL};
|
||||||
|
static _PyArg_Parser _parser = {"|y*zzz*", _keywords, 0};
|
||||||
Py_buffer data = {NULL, NULL};
|
Py_buffer data = {NULL, NULL};
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
const char *bpath = NULL;
|
const char *bpath = NULL;
|
||||||
Py_buffer spath = {NULL, NULL};
|
Py_buffer spath = {NULL, NULL};
|
||||||
PyObject *code = NULL;
|
PyObject *code = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|y*zzz*", _keywords, &data,
|
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwargs, &_parser, &data,
|
||||||
&name, &bpath, &spath)) {
|
&name, &bpath, &spath)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -2223,9 +2224,10 @@ exit:
|
||||||
}
|
}
|
||||||
PyDoc_STRVAR(_imp_compile_bytecode_doc, "compile bytecode to a code object");
|
PyDoc_STRVAR(_imp_compile_bytecode_doc, "compile bytecode to a code object");
|
||||||
|
|
||||||
static PyObject *_imp_validate_bytecode_header(PyObject *module, PyObject *args,
|
static PyObject *_imp_validate_bytecode_header(PyObject *module, PyObject **args,
|
||||||
PyObject *kwargs) {
|
Py_ssize_t nargs, PyObject *kwargs) {
|
||||||
static char *_keywords[] = {"data", "source_stats", "name", "path", NULL};
|
static const char * const _keywords[] = {"data", "source_stats", "name", "path", NULL};
|
||||||
|
static _PyArg_Parser _parser = {"|y*Ozz", _keywords, 0};
|
||||||
static const char defname[] = "<bytecode>";
|
static const char defname[] = "<bytecode>";
|
||||||
static const char defpath[] = "";
|
static const char defpath[] = "";
|
||||||
|
|
||||||
|
@ -2243,7 +2245,7 @@ static PyObject *_imp_validate_bytecode_header(PyObject *module, PyObject *args,
|
||||||
int64_t source_size = 0;
|
int64_t source_size = 0;
|
||||||
int64_t source_mtime = 0;
|
int64_t source_mtime = 0;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|y*Ozz", _keywords, &data,
|
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwargs, &_parser, &data,
|
||||||
&source_stats, &name, &path)) {
|
&source_stats, &name, &path)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -2300,15 +2302,16 @@ exit:
|
||||||
PyDoc_STRVAR(_imp_validate_bytecode_header_doc,
|
PyDoc_STRVAR(_imp_validate_bytecode_header_doc,
|
||||||
"validate first 12 bytes and stat info of bytecode");
|
"validate first 12 bytes and stat info of bytecode");
|
||||||
|
|
||||||
static PyObject *_imp_cache_from_source(PyObject *module, PyObject *args,
|
static PyObject *_imp_cache_from_source(PyObject *module, PyObject **args, Py_ssize_t nargs,
|
||||||
PyObject *kwargs) {
|
PyObject *kwargs) {
|
||||||
static char *_keywords[] = {"path", "debug_override", "optimization", NULL};
|
static const char * const _keywords[] = {"path", "debug_override", "optimization", NULL};
|
||||||
|
static struct _PyArg_Parser _parser = {"|OO$O:cache_from_source", _keywords, 0};
|
||||||
PyObject *path = NULL;
|
PyObject *path = NULL;
|
||||||
PyObject *debug_override = NULL;
|
PyObject *debug_override = NULL;
|
||||||
PyObject *optimization = NULL;
|
PyObject *optimization = NULL;
|
||||||
PyObject *res = NULL;
|
PyObject *res = NULL;
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO$O:cache_from_source",
|
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwargs, &_parser,
|
||||||
_keywords, &path, &debug_override,
|
&path, &debug_override,
|
||||||
&optimization)) {
|
&optimization)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2519,7 +2522,7 @@ static PyObject *SFLObject_get_filename(SourcelessFileLoader *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *SFLObject_load_module(SourcelessFileLoader *self,
|
static PyObject *SFLObject_load_module(SourcelessFileLoader *self,
|
||||||
PyObject *args) {
|
PyObject **args, Py_ssize_t nargs) {
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
PyObject *bootstrap = NULL;
|
PyObject *bootstrap = NULL;
|
||||||
PyObject *fullname = NULL;
|
PyObject *fullname = NULL;
|
||||||
|
@ -2527,7 +2530,7 @@ static PyObject *SFLObject_load_module(SourcelessFileLoader *self,
|
||||||
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
_Py_IDENTIFIER(_load_module_shim);
|
_Py_IDENTIFIER(_load_module_shim);
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|z:load_module", &name)) goto exit;
|
if (!_PyArg_ParseStack(args, nargs, "|z:load_module", &name)) goto exit;
|
||||||
if (!name) name = self->name;
|
if (!name) name = self->name;
|
||||||
if (strncmp(name, self->name, self->namelen)) {
|
if (strncmp(name, self->name, self->namelen)) {
|
||||||
PyErr_Format(PyExc_ImportError, "loader for %s cannot handle %s\n",
|
PyErr_Format(PyExc_ImportError, "loader for %s cannot handle %s\n",
|
||||||
|
@ -2558,8 +2561,6 @@ static PyObject *SFLObject_exec_module(SourcelessFileLoader *self,
|
||||||
PyObject *module = NULL;
|
PyObject *module = NULL;
|
||||||
PyObject *name = NULL;
|
PyObject *name = NULL;
|
||||||
PyObject *code = NULL;
|
PyObject *code = NULL;
|
||||||
PyObject *v = NULL;
|
|
||||||
PyObject *module_dict = NULL;
|
|
||||||
|
|
||||||
if (!PyArg_Parse(arg, "O:exec_module", &module)) goto exit;
|
if (!PyArg_Parse(arg, "O:exec_module", &module)) goto exit;
|
||||||
|
|
||||||
|
@ -2602,7 +2603,7 @@ static PyMethodDef SFLObject_methods[] = {
|
||||||
{"is_package", (PyCFunction)SFLObject_is_package, METH_O, PyDoc_STR("")},
|
{"is_package", (PyCFunction)SFLObject_is_package, METH_O, PyDoc_STR("")},
|
||||||
{"create_module", (PyCFunction)SFLObject_create_module, METH_O,
|
{"create_module", (PyCFunction)SFLObject_create_module, METH_O,
|
||||||
PyDoc_STR("")},
|
PyDoc_STR("")},
|
||||||
{"load_module", (PyCFunction)SFLObject_load_module, METH_VARARGS, PyDoc_STR("")},
|
{"load_module", (PyCFunction)SFLObject_load_module, METH_FASTCALL, PyDoc_STR("")},
|
||||||
{"exec_module", (PyCFunction)SFLObject_exec_module, METH_O, PyDoc_STR("")},
|
{"exec_module", (PyCFunction)SFLObject_exec_module, METH_O, PyDoc_STR("")},
|
||||||
{"get_filename", (PyCFunction)SFLObject_get_filename, METH_O,
|
{"get_filename", (PyCFunction)SFLObject_get_filename, METH_O,
|
||||||
PyDoc_STR("")},
|
PyDoc_STR("")},
|
||||||
|
@ -2654,9 +2655,9 @@ static PyMethodDef imp_methods[] = {
|
||||||
{"_r_long", _imp_r_long, METH_O, _imp_r_long_doc},
|
{"_r_long", _imp_r_long, METH_O, _imp_r_long_doc},
|
||||||
{"_relax_case", _imp_relax_case, METH_NOARGS, NULL},
|
{"_relax_case", _imp_relax_case, METH_NOARGS, NULL},
|
||||||
{"_write_atomic", (PyCFunction)_imp_write_atomic, METH_FASTCALL, _imp_write_atomic_doc},
|
{"_write_atomic", (PyCFunction)_imp_write_atomic, METH_FASTCALL, _imp_write_atomic_doc},
|
||||||
{"_compile_bytecode", (PyCFunction)_imp_compile_bytecode, METH_VARARGS | METH_KEYWORDS , _imp_compile_bytecode_doc},
|
{"_compile_bytecode", (PyCFunction)_imp_compile_bytecode, METH_FASTCALL | METH_KEYWORDS , _imp_compile_bytecode_doc},
|
||||||
{"_validate_bytecode_header", (PyCFunction)_imp_validate_bytecode_header, METH_VARARGS | METH_KEYWORDS , _imp_validate_bytecode_header_doc},
|
{"_validate_bytecode_header", (PyCFunction)_imp_validate_bytecode_header, METH_FASTCALL | METH_KEYWORDS , _imp_validate_bytecode_header_doc},
|
||||||
{"cache_from_source", (PyCFunction)_imp_cache_from_source, METH_VARARGS | METH_KEYWORDS , _imp_cache_from_source_doc},
|
{"cache_from_source", (PyCFunction)_imp_cache_from_source, METH_FASTCALL | METH_KEYWORDS , _imp_cache_from_source_doc},
|
||||||
{"source_from_cache", (PyCFunction)_imp_source_from_cache, METH_O , _imp_source_from_cache_doc},
|
{"source_from_cache", (PyCFunction)_imp_source_from_cache, METH_O , _imp_source_from_cache_doc},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue