Skip to content

Commit fbeec5a

Browse files
committed
Add more details to the readme
1 parent b0556a5 commit fbeec5a

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,24 @@ More usage please check the unittest.
7979
## Python bindings
8080

8181
The library can be used in Python via pybind11 bindings.
82-
Since util_caching is a template library, we need to explicitly instantiate the template for the types we want to use in Python.
83-
For this, we provide the convenience functions `bindNumberBasedCache` and `bindTimeBasedCache`.
84-
Check the unit test for a usage example.
82+
Since util_caching is a template library,
83+
you need to explicitly instantiate the template for the types you want to use in Python.
84+
For this, we provide convenience functions to bind the library for the desired types.
85+
Simply call them in a pybind11 module definition, e.g.:
86+
87+
```cpp
88+
PYBIND11_MODULE(util_caching, m) {
89+
python_api::number_based::bindCache<double, double>(m);
90+
}
91+
```
92+
and use them in Python:
93+
94+
```python
95+
from util_caching import Cache
96+
cache = Cache()
97+
cache.cache(1.0, 2.0)
98+
```
99+
We re-implemented all of the C++ unit tests in Python, so take a closer look at those for more advanced usage examples.
85100

86101

87102
## Installation
@@ -110,6 +125,7 @@ find_package(util_caching REQUIRED)
110125

111126
First make sure all dependencies are installed:
112127
- [Googletest](https://github.com/google/googletest) (only if you want to build unit tests)
128+
- [pybind11](https://pybind11.readthedocs.io/en/stable/) (only if you want to build Python bindings and unit tests)
113129

114130
See also the [`Dockerfile`](./Dockerfile) for how to install these packages under Debian or Ubuntu.
115131

0 commit comments

Comments
 (0)