Huge Dicts and perfomance

Stephen D Evans sde at recombinant.demon.co.uk
Thu Dec 20 13:49:39 EST 2001


Are you using a list for the first index ? e.g. using list comprehensions:

dict = [ {} for i in range(2) ] # create a list of dictionaries
dict[0][objectname] = object
dict[1][(obj-a, obj-b)] = obj(a, b)

This should give a slight performance increase.

Which version of python are you using? Some windows versions run noticeably
slower than others with large amounts of data. (As an observation - the
cygwin http://sources.redhat.com/cygwin/ version runs faster on the windows
platform when using large dictionaries.)

Stephen D Evans

A picture speaks a thousand words.
"Lucio Torre" <lucio at movilogic.com> wrote in message
news:mailman.1008865945.12538.python-list at python.org...
> Hi,
>
> I am making an application where i want to store links betwen nodes. So
> i have a dictionary where i store the objects.
>
> dict[0][objectname] = object
>
> the [0] is because i to signify a link betwen obj-a and obj-b, i do:
>
> dict[1][(obj-a, obj-b)] = obj(a, b)
>
> and so on, to six levels deep.
>
> and i also store links betwen dict[x][y] and other nodes (the stored
> object has those links)
>
> and i want to say for example, if i have a and b, what other nodes
> usually come togheter? so i follow the links and find the root nodes (z,
> x) and the groups (a, z) and (s, x).
>
> the main problem of course is that doing it this way, performance sucks.
> I took me nothing to code it, but it takes to much to run (more than
> coding). So, any ideas on how to achieve my goal in a better (faster) way?
>
> thanks,
>
> Lucio.
>
>
>





More information about the Python-list mailing list