If you decide to go with the C dict option, you can use the C++ STL's std::map. It's unlikely that you'll find faster or more robust native code that implements a dictionary/map.
cppmap.pyx:
# distutils: language = c++
cdef extern from "<map>" namespace "std":
cdef cppclass mymap "std::map<int, float>":
mymap()
float& operator[] (const int& k)
cdef mymap m = mymap()
cdef int i
cdef float value
for i in range(100):
value = 3.0 * i**2
m[i] = value
print m[10]
setup.py:
from distutils.core import setup
from Cython.Build import cythonize
setup(name = "cppmapapp"
ext_modules = cythonize('*.pyx'))
Command line:
$ python setup.py build
$ cd build/lib.macosx-10.5-x86_64-2.7
$ python -c 'import cppmap'
300.0