Getting values with the right type in Redis
As @favoretti said, response callbacks will do the trick. It's not complicate at all, just one line and all will be taken care of.
In [2]: import redis
In [3]: r = redis.Redis()
In [10]: r.set_response_callback('HGET', float)
In [11]: r.hget('myhash', 'field0')
Out[11]: 4.6
for hmget
, it returns a list of strings, not one single string, so you need to construct a little more comprehensive callback function:
In [12]: r.set_response_callback('HMGET', lambda l: [float(i) for i in l])
In [13]: r.hmget('myhash', 'field0')
Out[13]: [4.6]
same for hgetall
.
Technically speaking you need to take care of that on your own.
However, have a look at this link, especially at the part of their README that refers to parsers and response callbacks, maybe that's something you can use. Question would be whether this is an overkill for you or not.