M
m.barenco
Hello,
I am considering using dictionnaries as lookup tables e.g.
and I would like to have a dictionnary method returning the key and
item of the dictionnary whose key is smaller than the input of the
None (or some error message)
Now, I know that dictionnaries are stored in a non-ordered fashion in
python but they are so efficient in recovering values (at least wrt
lists) that it suggests me that internally there is some ordering. I
might be totally wrong because I don't know how the hashing is really
done. Of course I would use such methods in much larger tables. So is
this possible or should I stick to my own class with O(log2(N))
recovery time?
Note that when I type:['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__',
'__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__',
'__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__',
'__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy',
'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys',
'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update',
'values']
the functions __ge__, __gt__, __lt__, __le__ seem to be non-implemented
but there is some __doc__ in them. Is there the intention to do
something similar as is described above or are they here for some
(future) dictionnary comparison purposes?
Thanks a lot!
Martino
I am considering using dictionnaries as lookup tables e.g.
and I would like to have a dictionnary method returning the key and
item of the dictionnary whose key is smaller than the input of the
None (or some error message)
Now, I know that dictionnaries are stored in a non-ordered fashion in
python but they are so efficient in recovering values (at least wrt
lists) that it suggests me that internally there is some ordering. I
might be totally wrong because I don't know how the hashing is really
done. Of course I would use such methods in much larger tables. So is
this possible or should I stick to my own class with O(log2(N))
recovery time?
Note that when I type:['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__',
'__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__',
'__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__',
'__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy',
'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys',
'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update',
'values']
the functions __ge__, __gt__, __lt__, __le__ seem to be non-implemented
but there is some __doc__ in them. Is there the intention to do
something similar as is described above or are they here for some
(future) dictionnary comparison purposes?
Thanks a lot!
Martino