summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Setup1
-rw-r--r--Modules/_typingmodule.c59
-rw-r--r--Modules/clinic/_typingmodule.c.h12
3 files changed, 72 insertions, 0 deletions
diff --git a/Modules/Setup b/Modules/Setup
index 87c6a15..5e26472 100644
--- a/Modules/Setup
+++ b/Modules/Setup
@@ -184,6 +184,7 @@ _symtable symtablemodule.c
#_asyncio _asynciomodule.c # Fast asyncio Future
#_json -I$(srcdir)/Include/internal -DPy_BUILD_CORE_BUILTIN _json.c # _json speedups
#_statistics _statisticsmodule.c # statistics accelerator
+#_typing _typingmodule.c # typing accelerator
#unicodedata unicodedata.c -DPy_BUILD_CORE_BUILTIN # static Unicode character database
diff --git a/Modules/_typingmodule.c b/Modules/_typingmodule.c
new file mode 100644
index 0000000..8b6faa6
--- /dev/null
+++ b/Modules/_typingmodule.c
@@ -0,0 +1,59 @@
+/* typing accelerator C extension: _typing module. */
+
+#include "Python.h"
+#include "clinic/_typingmodule.c.h"
+
+/*[clinic input]
+module _typing
+
+[clinic start generated code]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=1db35baf1c72942b]*/
+
+/* helper function to make typing.NewType.__call__ method faster */
+
+/*[clinic input]
+_typing._idfunc -> object
+
+ x: object
+ /
+
+[clinic start generated code]*/
+
+static PyObject *
+_typing__idfunc(PyObject *module, PyObject *x)
+/*[clinic end generated code: output=63c38be4a6ec5f2c input=49f17284b43de451]*/
+{
+ Py_INCREF(x);
+ return x;
+}
+
+
+static PyMethodDef typing_methods[] = {
+ _TYPING__IDFUNC_METHODDEF
+ {NULL, NULL, 0, NULL}
+};
+
+PyDoc_STRVAR(typing_doc,
+"Accelerators for the typing module.\n");
+
+static struct PyModuleDef_Slot _typingmodule_slots[] = {
+ {0, NULL}
+};
+
+static struct PyModuleDef typingmodule = {
+ PyModuleDef_HEAD_INIT,
+ "_typing",
+ typing_doc,
+ 0,
+ typing_methods,
+ _typingmodule_slots,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC
+PyInit__typing(void)
+{
+ return PyModuleDef_Init(&typingmodule);
+}
diff --git a/Modules/clinic/_typingmodule.c.h b/Modules/clinic/_typingmodule.c.h
new file mode 100644
index 0000000..ea415e6
--- /dev/null
+++ b/Modules/clinic/_typingmodule.c.h
@@ -0,0 +1,12 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_typing__idfunc__doc__,
+"_idfunc($module, x, /)\n"
+"--\n"
+"\n");
+
+#define _TYPING__IDFUNC_METHODDEF \
+ {"_idfunc", (PyCFunction)_typing__idfunc, METH_O, _typing__idfunc__doc__},
+/*[clinic end generated code: output=e7ea2a3cb7ab301a input=a9049054013a1b77]*/