Perform build and magnum tuning

Building o//third_party/python now takes 5 seconds on my PC

This change works towards modifying Python to use runtime dispatching
when appropriate. For example, when loading the magnums in the socket
module, it's a good idea to check if the magnum is zero, because that
means the local system platform doesn't support it.
This commit is contained in:
Justine Tunney 2021-08-10 10:26:13 -07:00
parent ee7e296339
commit d26d7ae0e4
1028 changed files with 6576 additions and 172777 deletions

View file

@ -1,3 +1,4 @@
/* clang-format off */
/*
An implementation of the new I/O lib as defined by PEP 3116 - "New I/O"
@ -8,21 +9,9 @@
*/
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "_iomodule.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif /* HAVE_SYS_STAT_H */
#ifdef MS_WINDOWS
#include <consoleapi.h>
#endif
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Modules/_io/_iomodule.h"
/* Various interned strings */
@ -638,7 +627,7 @@ iomodule_free(PyObject *mod) {
* Module definition
*/
#include "clinic/_iomodule.c.h"
#include "third_party/python/Modules/_io/clinic/_iomodule.inc"
static PyMethodDef module_methods[] = {
_IO_OPEN_METHODDEF

View file

@ -1,3 +1,4 @@
/* clang-format off */
/*
* Declarations shared between the different parts of the io module
*/

View file

@ -1,3 +1,4 @@
/* clang-format off */
/*
An implementation of Buffered I/O as defined by PEP 3116 - "New I/O"
@ -8,10 +9,10 @@
*/
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "pythread.h"
#include "_iomodule.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/pythread.h"
#include "third_party/python/Modules/_io/_iomodule.h"
/*[clinic input]
module _io
@ -2342,7 +2343,7 @@ _io_BufferedRandom___init___impl(buffered *self, PyObject *raw,
return 0;
}
#include "clinic/bufferedio.c.h"
#include "third_party/python/Modules/_io/clinic/bufferedio.inc"
static PyMethodDef bufferediobase_methods[] = {

View file

@ -1,6 +1,7 @@
#include "Python.h"
#include "structmember.h" /* for offsetof() */
#include "_iomodule.h"
/* clang-format off */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Modules/_io/_iomodule.h"
/*[clinic input]
module _io
@ -1009,7 +1010,7 @@ bytesio_clear(bytesio *self)
}
#include "clinic/bytesio.c.h"
#include "third_party/python/Modules/_io/clinic/bytesio.inc"
static PyGetSetDef bytesio_getsetlist[] = {
{"closed", (getter)bytesio_get_closed, NULL,

View file

@ -1,22 +1,10 @@
/* clang-format off */
/* Author: Daniel Stutzbach */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <stddef.h> /* For offsetof */
#include "_iomodule.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Modules/_io/_iomodule.h"
/*
* Known likely problems:
@ -1131,7 +1119,7 @@ fileio_getstate(fileio *self)
return NULL;
}
#include "clinic/fileio.c.h"
#include "third_party/python/Modules/_io/clinic/fileio.inc"
static PyMethodDef fileio_methods[] = {
_IO_FILEIO_READ_METHODDEF

View file

@ -1,3 +1,4 @@
/* clang-format off */
/*
An implementation of the I/O abstract base classes hierarchy
as defined by PEP 3116 - "New I/O"
@ -9,9 +10,9 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "_iomodule.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Modules/_io/_iomodule.h"
/*[clinic input]
module _io
@ -758,7 +759,7 @@ _io__IOBase_writelines(PyObject *self, PyObject *lines)
Py_RETURN_NONE;
}
#include "clinic/iobase.c.h"
#include "third_party/python/Modules/_io/clinic/iobase.inc"
static PyMethodDef iobase_methods[] = {
{"seek", iobase_seek, METH_VARARGS, iobase_seek_doc},

View file

@ -1,8 +1,9 @@
/* clang-format off */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "accu.h"
#include "_iomodule.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/accu.h"
#include "third_party/python/Modules/_io/_iomodule.h"
/* Implementation note: the buffer is always at least one character longer
than the enclosed string, for proper functioning of _PyIO_find_line_ending.
@ -1010,7 +1011,7 @@ stringio_newlines(stringio *self, void *context)
return PyObject_GetAttr(self->decoder, _PyIO_str_newlines);
}
#include "clinic/stringio.c.h"
#include "third_party/python/Modules/_io/clinic/stringio.inc"
static struct PyMethodDef stringio_methods[] = {
_IO_STRINGIO_CLOSE_METHODDEF

View file

@ -1,3 +1,4 @@
/* clang-format off */
/*
An implementation of Text I/O as defined by PEP 3116 - "New I/O"
@ -7,9 +8,9 @@
*/
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "_iomodule.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Modules/_io/_iomodule.h"
/*[clinic input]
module _io
@ -2829,7 +2830,7 @@ textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context)
return 0;
}
#include "clinic/textio.c.h"
#include "third_party/python/Modules/_io/clinic/textio.inc"
static PyMethodDef incrementalnewlinedecoder_methods[] = {
_IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF

View file

@ -1,3 +1,4 @@
/* clang-format off */
/*
An implementation of Windows console I/O
@ -8,23 +9,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifdef MS_WINDOWS
#include "structmember.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#include <stddef.h> /* For offsetof */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <fcntl.h>
#include "_iomodule.h"
#include "third_party/python/Modules/_io/_iomodule.h"
/* BUFSIZ determines how many characters can be typed at the console
before it starts blocking. */