pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/0d2d2b83935a516235f4dbce25aefad789d088cf

60c69660fa.css" /> Issue #18668: Properly document setting m_size in PyModuleDef · python/cpython@0d2d2b8 · GitHub
Skip to content

Commit 0d2d2b8

Browse files
committed
Issue #18668: Properly document setting m_size in PyModuleDef
1 parent 9ae513c commit 0d2d2b8

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Doc/c-api/module.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,22 @@ These functions are usually used in the module initialization function.
182182
183183
.. c:member:: Py_ssize_t m_size
184184
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`.
189188
190189
This memory should be used, rather than static globals, to hold per-module
191190
state, since it is then safe for use in multiple sub-interpreters. It is
192191
freed when the module object is deallocated, after the :c:member:`m_free`
193192
function has been called, if present.
194193
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+
195201
.. c:member:: PyMethodDef* m_methods
196202
197203
A pointer to a table of module-level functions, described by

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy