Skip to content

Commit

Permalink
Add more details to the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ll-nick committed Nov 11, 2024
1 parent b0556a5 commit fbeec5a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,24 @@ More usage please check the unittest.
## Python bindings

The library can be used in Python via pybind11 bindings.
Since util_caching is a template library, we need to explicitly instantiate the template for the types we want to use in Python.
For this, we provide the convenience functions `bindNumberBasedCache` and `bindTimeBasedCache`.
Check the unit test for a usage example.
Since util_caching is a template library,
you need to explicitly instantiate the template for the types you want to use in Python.
For this, we provide convenience functions to bind the library for the desired types.
Simply call them in a pybind11 module definition, e.g.:

```cpp
PYBIND11_MODULE(util_caching, m) {
python_api::number_based::bindCache<double, double>(m);
}
```
and use them in Python:
```python
from util_caching import Cache
cache = Cache()
cache.cache(1.0, 2.0)
```
We re-implemented all of the C++ unit tests in Python, so take a closer look at those for more advanced usage examples.


## Installation
Expand Down Expand Up @@ -110,6 +125,7 @@ find_package(util_caching REQUIRED)

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

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

Expand Down

0 comments on commit fbeec5a

Please sign in to comment.