Bindings

89 views
Skip to first unread message

Christian S. Perone

unread,
Aug 12, 2015, 4:00:02 PM8/12/15
to pm...@googlegroups.com
Hello, is there any roadmap or plans to create bindings of the NVML for other languages (other than C/C++) ?

Thanks !

--
"Forgive, O Lord, my little jokes on Thee, and I'll forgive Thy great big joke on me."

Piotr Balcer

unread,
Aug 13, 2015, 5:56:04 AM8/13/15
to pmem
Hi,
There are plans, but nothing too formal yet afaik. It's still pretty far off, we are not finished with the C library yet.
Writing a simple wrapper library for other languages is pretty straightforward, and could be done fairly quickly. We want to do more than that.

Our library uses a lot of macros to make using it more manageable in C.
We want to leverage meta-programming capabilities to make it look like an extension to the language itself rather than an out-of-place looking C library (Java opengl jGL bindings come to mind)

For example, instead of straight out using libpmemobj C interface in C++, we want to implement the same functionality using templates.

struct foo {
   
int bar;
};

void work() {
    obj::transaction(pop); /* transaction in this scope */

   
auto foop = obj::make_persistent<foo>(5);

    foop
->bar = 10; /* no D_RW() or TX_ADD(), overloaded operators instead */

   
/* no need to commit/end */
}

That would be really neat :) This type of C++ library is the first thing on the list, other languages may come latter.

Once and if I have the time, I myself plan to do something like this for golang, I know few people in the team want to do python bindings (I think that a simple wrapper library already exists, sadly not public).

Piotr

Christian S. Perone

unread,
Aug 13, 2015, 8:42:59 AM8/13/15
to Piotr Balcer, pmem
That's good news, thanks for the quick reply Piotr. I was planning to start a Python bindings project for fun but I guess I'll wait a little in case of API changes. The C++ interface looks a lot better than the C macros. I don't know if your Python bindings are already doing something like this but an elegant way to make such transactions in Python is probably using context managers like the example below:

with nvml.transaction(pop):
    # ... 
Pretty much like Django handle db transactions today.

Thanks !

--
You received this message because you are subscribed to the Google Groups "pmem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pmem+uns...@googlegroups.com.
To post to this group, send email to pm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pmem/62ca94a2-001c-4e26-be9b-cf9011f59e46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Piotr Balcer

unread,
Aug 13, 2015, 9:45:23 AM8/13/15
to pmem, ppbb...@gmail.com
Cool!
I cannot promise that we won't change API, but we don't plan to.

Our python thing uses ctypes to call functions 1:1. It's not really that useful. If you want to write proper bindings, by all means, go ahead ;) We might even support you in your effort.
I think that the one big thing that we can simplify using a higher-level language is to get rid of explicit calls to pmemobj_direct() and pmemobj_tx_add_range() everywhere (like in the C++ example I wrote).

Piotr
Reply all
Reply to author
Forward
0 new messages