Patch #1359618: Speed-up charmap encoder.
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 080fa74..32fa82f 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -792,6 +792,15 @@
return v;
}
+static PyObject*
+charmap_build(PyObject *self, PyObject *args)
+{
+ PyObject *map;
+ if (!PyArg_ParseTuple(args, "U:charmap_build", &map))
+ return NULL;
+ return PyUnicode_BuildEncodingMap(map);
+}
+
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
static PyObject *
@@ -897,6 +906,7 @@
{"ascii_decode", ascii_decode, METH_VARARGS},
{"charmap_encode", charmap_encode, METH_VARARGS},
{"charmap_decode", charmap_decode, METH_VARARGS},
+ {"charmap_build", charmap_build, METH_VARARGS},
{"readbuffer_encode", readbuffer_encode, METH_VARARGS},
{"charbuffer_encode", charbuffer_encode, METH_VARARGS},
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)