C++ and Python bindings
Yokan provides C++ and Python bindings.
C++ bindings are headers-only and located in include/yokan/cxx/.
The API is pretty much self-explanatory: it provides C++ class
equivalent to the corresponding C opaque pointers and identifiers.
For instance the
yokan::Client class can be used in place of
the yk_client_t C equivalent.
Some C++ functions may have their parameters in a different order than the corresponding C function (in particular all the functions that take a mode have this mode as last parameter). This is to allow C++ optional parameters.
Yokan also provides Python bindings for its server, admin, and client
libraries. The best way to understand their use is to look in the
tests/python folder. To enable this python binding, install Yokan
+python variant in spack.
The Python binding aim to encourage the user to think about performance
first, before thinking about usability. We encourage users to implement
a higher-level API on top of Yokan’s API to suit their particular user-case.
For instance, the Python API does not provide
__iter__ capabilities to
enable seemless iteration through key/value pairs. This kind of functionality
would need to be implemented by the user using the
with the added knowledge of desired batch sizes, buffer sizes, etc.
All functions in the Python bindings take either a string, or
any object that implements the buffer protocol.
Such objects include, for instance,
bytearray and numpy arrays.
Using objects satisfying the buffer protocol will be more efficient
than using strings because the latter causes memory copies to occur
when the Python string is converted into a C++ string internally.