10000 gh-103092: Isolate _collections by erlend-aasland · Pull Request #103093 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-103092: Isolate _collections #103093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 12, 2023
Merged
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
Prev Previous commit
Next Next commit
Add module level helpers
  • Loading branch information
erlend-aasland committed Mar 28, 2023
commit 3d7fd7ccdefe6188fd8bec4a0df7af58019e372e
47 changes: 38 additions & 9 deletions Modules/_collectionsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2540,6 +2540,24 @@ static PyTypeObject tuplegetter_type = {

/* module level code ********************************************************/

static int
collections_traverse(PyObject *module, visitproc visit, void *arg)
{
return 0;
}

static int
collections_clear(PyObject *module)
{
return 0;
}

static void
collections_free(void *module)
{
collections_clear((PyObject *)module);
}

PyDoc_STRVAR(collections_doc,
"High performance data structures.\n\
- deque: ordered collection accessible from endpoints only\n\
Expand All @@ -2551,6 +2569,18 @@ static struct PyMethodDef collections_methods[] = {
{NULL, NULL} /* sentinel */
};

#define ADD_TYPE(mod, spec, type) \
do { \
type = (PyTypeObject *)PyType_FromModuleAndSpec(mod, spec, NULL); \
if (type == NULL) { \
return -1; \
} \
if (PyModule_AddType(mod, type) < 0) { \
return -1; \
} \
return 0; \
} while (0)

static int
collections_exec(PyObject *module) {
PyTypeObject *typelist[] = {
Expand Down Expand Up @@ -2579,15 +2609,14 @@ static struct PyModuleDef_Slot collections_slots[] = {
};

static struct PyModuleDef _collectionsmodule = {
PyModuleDef_HEAD_INIT,
"_collections",
collections_doc,
0,
collections_methods,
collections_slots,
NULL,
NULL,
NULL
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "_collections",
.m_doc = collections_doc,
.m_methods = collections_methods,
.m_slots = collections_slots,
.m_traverse = collections_traverse,
.m_clear = collections_clear,
.m_free = collections_free,
};

PyMODINIT_FUNC
Expand Down
0