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 Oct 21, 2024
1 parent 6ceb005 commit 2d872aa
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 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

0 comments on commit 2d872aa

Please sign in to comment.