-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathpybind.cpp
More file actions
67 lines (58 loc) · 2.3 KB
/
pybind.cpp
File metadata and controls
67 lines (58 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* @brief Python bindings for Universal Key-Values.
*
* ## Features
*
* - Zero-Copy data forwarding into Python runtime
* https://stackoverflow.com/questions/58113973/returning-multiple-pyarray-without-copying-in-pybind11
* - Calls the C functions outside of the Global Interpret Lock
* https://stackoverflow.com/a/55205951
*
* ## Low-level CPython bindings
*
* The complexity of implementing the low-level interface boils
* down to frequent manual calls to `PyArg_ParseTuple()`.
* It also gives us a more fine-grained control over `PyGILState_Release()`.
* https://docs.python.org/3/extending/extending.html
* https://realpython.com/build-python-c-extension-module/
* https://docs.python.org/3/c-api/arg.html
* https://docs.python.org/3/c-api/mapping.html
* https://docs.python.org/3/c-api/init.html#thread-state-and-the-global-interpreter-lock
*
* ## High-level Python bindings generators
*
* https://realpython.com/python-bindings-overview/
* http://blog.behnel.de/posts/cython-pybind11-cffi-which-tool-to-choose.html
* https://pythonspeed.com/articles/python-extension-performance/
* https://github.com/wjakob/nanobind
* https://wiki.python.org/moin/IntegratingPythonWithOtherLanguages
*/
#include "pybind.hpp"
using namespace unum::ustore;
using namespace unum;
#define stringify_value_m(a) stringify_m(a)
#define stringify_m(a) #a
PYBIND11_MODULE(USTORE_PYTHON_MODULE_NAME, m) {
m.attr("__name__") = "ustore." stringify_value_m(USTORE_PYTHON_MODULE_NAME);
m.doc() = R"doc(
======================================================
Python bindings for Universal Key Value store library.
======================================================
Supports:
**********
* Collection-level CRUD operations, like `dict`.
* Batch operations & ACID transactions.
* Graph collections, mimicking `networkx`.
* Tabular views, mimicking `pandas`.
* Apache Arrow exports for inter-process communication.
)doc";
if (arrow::py::import_pyarrow())
throw std::runtime_error("Failed to initialize PyArrow");
wrap_database(m);
wrap_pandas(m);
wrap_networkx<graph_k>(m, "Graph");
wrap_networkx<digraph_k>(m, "DiGraph");
wrap_networkx<multigraph_k>(m, "MultiGraph");
wrap_networkx<multidigraph_k>(m, "MultiDiGraph");
wrap_document(m);
}