Comments (6)
Why can't you just coerce these numpy values to regular Python objects? The issue is probably here:
cdef python_to_unqlite_value(VM vm, unqlite_value *ptr, python_value):
cdef unqlite_value *item_ptr = <unqlite_value *>0
cdef bytes encoded_value
if isinstance(python_value, unicode):
encoded_value = python_value.encode('utf-8')
unqlite_value_string(ptr, encoded_value, -1)
elif isinstance(python_value, bytes):
unqlite_value_string(ptr, python_value, -1)
elif isinstance(python_value, (list, tuple)):
for item in python_value:
item_ptr = vm.create_value(item)
unqlite_array_add_elem(ptr, NULL, item_ptr)
vm.release_value(item_ptr)
elif isinstance(python_value, dict):
for key, value in python_value.items():
if not isinstance(key, basestring):
key = str(key)
if isinstance(key, unicode):
key = key.encode('utf-8')
item_ptr = vm.create_value(value)
unqlite_array_add_strkey_elem(
ptr,
<const char *>key,
item_ptr)
vm.release_value(item_ptr)
elif isinstance(python_value, bool):
unqlite_value_bool(ptr, python_value)
elif isinstance(python_value, (int, long)):
unqlite_value_int64(ptr, python_value)
elif isinstance(python_value, float):
unqlite_value_double(ptr, python_value)
else:
unqlite_value_null(ptr)
I'd need to add checks for all the numpy types, which is not really something I'm interested in doing.
from unqlite-python.
Hi! Well, at some point I would like to have np.uint64
values, which based on the code above would overflow at 2^63 in your system due to a coercion to signed integer 64.
from unqlite-python.
Then there's the additional point that anyone storing values only from 0-255 will be using eight times as much memory/disk space as needed for their np.uint8
stored as int64
from unqlite-python.
In my current use case, I would like to store many millions of uint32 values. I know four bytes is always enough. Your database is currently making me to use twice as much memory and disk space as needed by coercing everything to int64.
from unqlite-python.
If you could reopen this issue, I can start work on a pull request to properly account for numpy types.
from unqlite-python.
I'm not necessarily interested in supporting the numpy types. Additionally, I think unqlite uses 64-bit integers on the backend anyways, for all integers.
from unqlite-python.
Related Issues (20)
- collection fetch, anyway it will return a value HOT 1
- Update db entry in multiple threads HOT 6
- Question about multithread HOT 2
- Use in multi-process environment? HOT 2
- Flags unavailable via Python HOT 2
- Retrieved values are byte strings (Python 3.7) HOT 6
- Wrong kwarg name in UnQLite() API docs.
- AsyncIO Support? HOT 5
- ValueError when inserting to nonexistent collection HOT 2
- collection.store returs int HOT 3
- empty_collection.last_record_id() is 0 HOT 1
- FR: Binary releases on PyPI HOT 3
- Collection cursor only returns first record HOT 16
- Collection reverse iterator HOT 1
- Unqlite on python 3.10 fails with unqlite.cpython-310-x86_64-linux-gnu.so: undefined symbol: _PyGen_Send HOT 8
- Readme update HOT 1
- Import error HOT 3
- Is it possible to use a samba shared database file? HOT 1
- Cannot install unqlite 0.9.4 on Windows HOT 3
- Latest pip install asks for moving away from setup.py HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unqlite-python.