On Wednesday 02 September 2009 18:01:43 Robert Bradshaw wrote:
> On Sep 2, 2009, at 5:34 AM, Sanne Korzec wrote:
> > Hi mailing,
> >
> > I’ve been writing a complex program in python, which I am currently
> > scaling up. I find myself in the position now, where I run out of
> > memory or out of time. I have been looking at alternatives like
> > cython and ctypes. I implemented ctypes which fixes the memory
> > problem but doubles the time problem.
> >
> > Currently I am implementing a cython version and ran into a
> > problem. I hope someone can help me out.
> >
> > The main bottleneck in my code is a large dictionary / hash table
> > which I would like to optimize. Since a dictionary is a python
> > datatype I have no idea how to make this cython.
> >
> > Currently I have tried to keep the ‘keys’ intact and store the
> > ‘values’ as ctypes floats, but I think it might be better to do
> > something else. Do I need to make the entire hash table c? Or is
> > there a more simple solution like combining the python dict with
> > cython? If so, how do I do this?
> >
> > Thanks in advance.
> >
> > Additional details: I use a double dict where the key of the first
> > dict stores another dict as value.
> >
> > S.
>
> The short answer is yes, to avoid using the Python dictionary (which
> can only hold Python objects), you need to write your own hashtable.
> That's not very hard though--I bet only a hundred or two lines in
> Cython would be sufficient (and very fast). You could also look into
> using an external C or C++ library, though C++ support is still a
> work in progress.

I'd recommand using this C library:
http://c-algorithms.sourceforge.net/

having a cython-stl sounds nice though :)

cheers,
sebastien.
-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to