Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python bindings #30

Closed
sepeth opened this issue Dec 8, 2013 · 13 comments
Closed

python bindings #30

sepeth opened this issue Dec 8, 2013 · 13 comments

Comments

@sepeth
Copy link
Contributor

sepeth commented Dec 8, 2013

I am planning to code rocksdb bindings for python. So far, I am able to use basic rocksdb functionality in python :)

I think, I will use python ctypes and rocksdb C API. ATM, rocksdb/include/c.h is almost the same with leveldb counterpart (eg. all function names and structs starts with leveldb). Will you keep it that way, or do you plan to change it? or I can maintain and take care of that part happily :)

As a second option, I can directly use rocksdb C++ API, by writing CPython extension. But the outcome won't be portable between different python implementations and will only work with CPython.

What do you think about that?

@dhruba
Copy link
Contributor

dhruba commented Dec 9, 2013

The rocksdb C++ api is far more richer than the leveldb api. But we have (sadly) failed to enhance the C api in the same way. If you would like to bring the C api in par with C++ api, that will be a great contribution to the rocksdb github repo.

@sepeth
Copy link
Contributor Author

sepeth commented Dec 9, 2013

Great then, I am on it :)

@igorcanadi
Copy link
Collaborator

@sepeth Feel free to change leveldb_* in c.h to rocksdb_* and send us a pull request :)

@juneng603
Copy link

👍

@sepeth if you want to some hands for your contributions, I could be with you. :)

@sepeth
Copy link
Contributor Author

sepeth commented Dec 10, 2013

@igorcanadi I sent it :)

@junyoungKim Great :) I started with renames, and I will keep c-api branch updated in my fork as I progress. We can continue from there, I think.

@juneng603
Copy link

@sepeth ok, I've checked your branch for the jobs. Lets think about how we can implement it in a best way.

@forhappy
Copy link

I find that rocksdb's C API is much the same with leveldb's C API, I have written a python leveldb binding based on its C API before(https://github.com/forhappy/cpy-leveldb), so I can make it for rocksdb much easier, I'm on it too ;-).

@stephan-hof
Copy link

Hi @sepeth have you considered other methods for wrapping ?

For example Cython has great capabilities to wrap c++ code and the generated code works under python2 and python3

Only drawback, it generates code for cPython only. For a more 'interpreter-independent' way you should also check out CFFI. The 'wrap-performance' on pypy is outstanding (because the JIT knows of the C-functions and types and calls them directly) and on cPython comparable to ctypes.

However I don't know the status of CFFI for Jython/IronPython, but if you really target this two interpreters you should also check if they support ctypes properly.

@ramanala
Copy link

Hello @sepeth , Any idea on when the python bindings for RocksDB will be available?

@sepeth
Copy link
Contributor Author

sepeth commented Dec 31, 2013

@ramanala hello, hardest part of it is to complete C api, I believe. I've been doing somethings on that part (but some other things in my life kept me away from doing it), and still stuck with merge operator. In the mean time, I am playing with rocksdb from python. It seems easy to do with ctypes.

@stephan-hof Thank you. I am also considering CFFI, beside ctypes. and also pypy seems to suggest CFFI too.

@stephan-hof
Copy link

Hi guys, I also started python bindings for rocksdb.
Code here https://github.com/stephan-hof/pyrocksdb and the docs here http://pyrocksdb.readthedocs.org/

I'm using cython to wrap the C++ bindings directly.
I know this makes it impossible to use them under pypy, but I had a couple of reasons to do it

  • Experience with Cython (was using it to wrap other c++ libraries).
  • Cython has good capabilities to wrap C++, for example automatic exception conversion.
  • No dependencies on rocksdb C-API. As mentioned above the C-API lacks behind the features of the C++ driver and it seems to me the new features are implemented in C++ first.

The driver is still not complete yet, for example a python prefix_extractor is not possible, but the basic operations are already possible. Everything mentioned in the docs (like merge operator) should work.

Give it a try, I would be happy for everybody who would like to join the development.

@igorcanadi
Copy link
Collaborator

Closing the issue since it's stale. Thank you everybody for contributing to python bindings!

spetrunia pushed a commit to spetrunia/rocksdb that referenced this issue Jun 19, 2019
Nazgolze pushed a commit to Nazgolze/rocksdb-1 that referenced this issue Sep 21, 2021
iterator: Start on correct value when reverse=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@sepeth @dhruba @stephan-hof @forhappy @igorcanadi @juneng603 @ramanala and others