summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/module.rst
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-08-07 12:54:28 (GMT)
committerEli Bendersky <eliben@gmail.com>2013-08-07 12:54:28 (GMT)
commit7533137f4e1c78fda6041175f220bf1f77ee95a5 (patch)
tree226d671c72c91c84004d407594e55e5bb2c9d438 /Doc/c-api/module.rst
parent236a547b3e5094150e579eebb0152e98a4098dd3 (diff)
parent0d2d2b83935a516235f4dbce25aefad789d088cf (diff)
downloadcpython-7533137f4e1c78fda6041175f220bf1f77ee95a5.zip
cpython-7533137f4e1c78fda6041175f220bf1f77ee95a5.tar.gz
cpython-7533137f4e1c78fda6041175f220bf1f77ee95a5.tar.bz2
Closing #18668: Properly document setting m_size in PyModuleDef
Diffstat (limited to 'Doc/c-api/module.rst')
-rw-r--r--Doc/c-api/module.rst14
1 files changed, 10 insertions, 4 deletions
diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst
index 95a0169..92bfd5e 100644
--- a/Doc/c-api/module.rst
+++ b/Doc/c-api/module.rst
@@ -189,16 +189,22 @@ These functions are usually used in the module initialization function.
.. c:member:: Py_ssize_t m_size
- If the module object needs additional memory, this should be set to the
- number of bytes to allocate; a pointer to the block of memory can be
- retrieved with :c:func:`PyModule_GetState`. If no memory is needed, set
- this to ``-1``.
+ Some modules allow re-initialization (calling their ``PyInit_*`` function
+ more than once). These modules should keep their state in a per-module
+ memory area that can be retrieved with :c:func:`PyModule_GetState`.
This memory should be used, rather than static globals, to hold per-module
state, since it is then safe for use in multiple sub-interpreters. It is
freed when the module object is deallocated, after the :c:member:`m_free`
function has been called, if present.
+ Setting ``m_size`` to a positive value specifies the size of the additional
+ memory required by the module. Setting it to ``-1`` means that the module can
+ not be re-initialized because it has global state. Setting it to ``0`` is
+ forbidden.
+
+ See :PEP:`3121` for more details.
+
.. c:member:: PyMethodDef* m_methods
A pointer to a table of module-level functions, described by