Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add the _interpreters module to the stdlib.
  • Loading branch information
ericsnowcurrently committed May 23, 2017
commit 7cc14ad04ab4dc2456851590f3240f234e348d43
37 changes: 37 additions & 0 deletions Doc/library/_interpreters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
:mod:`_interpreters` --- Low-level interpreters API
===================================================

.. module:: _interpreters
:synopsis: Low-level interpreters API.

.. versionadded:: 3,7

:ref:`_sub-interpreter-support`

threading

--------------

This module provides low-level primitives for working with multiple
Python interpreters in the same process.

.. XXX The :mod:`interpreters` module provides an easier to use and
higher-level API built on top of this module.

This module is optional. It is provided by Python implementations which
support multiple interpreters.

.. XXX For systems lacking the :mod:`_interpreters` module, the
:mod:`_dummy_interpreters` module is available. It duplicates this
module's interface and can be used as a drop-in replacement.

It defines the following functions:


.. XXX TBD


**Caveats:**

* ...

11 changes: 11 additions & 0 deletions Lib/test/test__interpreters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest
from test import support
interpreters = support.import_module('_interpreters')


class InterpretersTests(unittest.TestCase):
pass


if __name__ == "__main__":
unittest.main()
43 changes: 43 additions & 0 deletions Modules/_interpretersmodule.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

/* interpreters module */
/* low-level access to interpreter primitives */

#include "Python.h"


static PyMethodDef module_functions[] = {
{NULL, NULL} /* sentinel */
};


/* initialization function */

PyDoc_STRVAR(module_doc,
"This module provides primitive operations to manage Python interpreters.\n\
The 'interpreters' module provides a more convenient interface.");

static struct PyModuleDef interpretersmodule = {
PyModuleDef_HEAD_INIT,
"_interpreters",
module_doc,
-1,
module_functions,
NULL,
NULL,
NULL,
NULL
};


PyMODINIT_FUNC
PyInit__interpreters(void)
{
PyObject *module;

module = PyModule_Create(&interpretersmodule);
if (module == NULL)
return NULL;


return module;
}
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ def detect_modules(self):
# syslog daemon interface
exts.append( Extension('syslog', ['syslogmodule.c']) )

# Python interface to subinterpreter C-API.
exts.append(Extension('_interpreters', ['_interpretersmodule.c']))

#
# Here ends the simple stuff. From here on, modules need certain
# libraries, are platform-specific, or present other surprises.
Expand Down