I would like to use leveldb to store integers and integer arrays efficiently, in both c++ and python.
For integers in C++, i could convert the int to a char array. Any suggestions for storing the int array in c++ and int and int array in python?
You could consider using a library like Google's protobuf (http://code.google.com/p/protobuf/) which is capable of (de)serializing structured data. For the case you mention, a repeated field would do the trick:
message List {
repeated int64 val = 1;
}
Given the varint encoding used by protocol buffers (and depending on your range of values) this could be an efficient way to store the integers.
http://code.google.com/apis/protocolbuffers/docs/encoding.html#varints
It is tough to say more without knowing a bit more about your use case. How many integers are going to be stored per array on average? What is the range of integer values? etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With