Skip to content

Commit 926b0cb

Browse files
authored
bpo-36641: Add "const" to PyDoc_VAR macro (GH-12854)
It reduces "data" segment in python about 200KB.
1 parent 31e8d69 commit 926b0cb

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Include/pymacro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868

6969
/* Define macros for inline documentation. */
70-
#define PyDoc_VAR(name) static char name[]
70+
#define PyDoc_VAR(name) static const char name[]
7171
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
7272
#ifdef WITH_DOC_STRINGS
7373
#define PyDoc_STR(str) str
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:c:macro:`PyDoc_VAR(name)` and :c:macro:`PyDoc_STRVAR(name,str)` now create
2+
``static const char name[]`` instead of ``static char name[]``. Patch by Inada Naoki.

Modules/_ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ SSLError_str(PyOSErrorObject *self)
557557

558558
static PyType_Slot sslerror_type_slots[] = {
559559
{Py_tp_base, NULL}, /* Filled out in module init as it's not a constant */
560-
{Py_tp_doc, SSLError_doc},
560+
{Py_tp_doc, (void*)SSLError_doc},
561561
{Py_tp_str, SSLError_str},
562562
{0, 0},
563563
};

0 commit comments

Comments
 (0)