File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -182,16 +182,22 @@ These functions are usually used in the module initialization function.
182
182
183
183
.. c :member :: Py_ssize_t m_size
184
184
185
- If the module object needs additional memory, this should be set to the
186
- number of bytes to allocate; a pointer to the block of memory can be
187
- retrieved with :c:func: `PyModule_GetState `. If no memory is needed, set
188
- this to ``-1 ``.
185
+ Some modules allow re-initialization (calling their ``PyInit_* `` function
186
+ more than once). These modules should keep their state in a per-module
187
+ memory area that can be retrieved with :c:func:`PyModule_GetState`.
189
188
190
189
This memory should be used, rather than static globals, to hold per-module
191
190
state, since it is then safe for use in multiple sub-interpreters. It is
192
191
freed when the module object is deallocated, after the :c:member:`m_free`
193
192
function has been called, if present.
194
193
194
+ Setting ``m_size`` to a positive value specifies the size of the additional
195
+ memory required by the module. Setting it to ``-1`` means that the module can
196
+ not be re-initialized because it has global state. Setting it to ``0`` is
197
+ forbidden.
198
+
199
+ See :PEP:`3121` for more details.
200
+
195
201
.. c:member:: PyMethodDef* m_methods
196
202
197
203
A pointer to a table of module-level functions, described by
You can’t perform that action at this time.
0 commit comments