-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code for defining C++ backend for tree algorithms.
- Loading branch information
1 parent
cf62fc5
commit 9642c68
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <Python.h> | ||
#include "trees.hpp" // Header file containing C++ implementations of wrapper functions of tree data structures | ||
|
||
// Method definitions | ||
static PyMethodDef trees_PyMethodDef[] = { | ||
{"binary_tree", (PyCFunction) binary_tree, METH_VARARGS, ""}, | ||
// Add method definitions for other tree data structures over here. | ||
{NULL, NULL, 0, NULL} /* Sentinel */ | ||
}; | ||
|
||
// Sentinel info: | ||
// The sentinel entry {NULL, NULL, 0, NULL} is used to indicate the end of the method definition array. | ||
// When the Python interpreter processes this array, it stops iterating over the array when it encounters this sentinel entry. | ||
|
||
// Module structure | ||
static struct PyModuleDef trees_module = { | ||
PyModuleDef_HEAD_INIT, | ||
"_trees", | ||
NULL, | ||
-1, | ||
trees_PyMethodDef | ||
}; | ||
|
||
// Module initialization function | ||
PyMODINIT_FUNC PyInit__trees(void) { | ||
PyObject *module; | ||
module = PyModule_Create(&trees_module); | ||
if (module == NULL) | ||
return NULL; | ||
return module; | ||
} |