Huge Dicts and perfomance

Jason Orendorff jason at jorendorff.com
Thu Dec 20 12:02:44 EST 2001


This is an interesting problem.  I have a few questions...

> 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.

I think I see.  Is it kind of like this?
  dict[0][a.name] = a
  dict[1][(a.name, b.name)] = LinkObject(a, b)

But I still can't tell what you mean by "six levels deep".
Is it like this?
  dict[2][(a.name, b.name, c.name)] = LinkObject(a, b, c)
  dict[3][(a.name, b.name, c.name, d.name)] = LinkObject(a, b, c, d)
  etc.

Or is it like this?
  dict[2][(link1.name, link2.name)] = MetaLinkObject(link1, link2)
  dict[3][(mlink1.name, mlink2.name)] = MetaMetaLinkObject(mlink1, mlink2)
  etc.

Or something else?


> and i also store links betwen dict[x][y] and other nodes (the stored
> object has those links)

All right... part of what's confusing me is the words "object",
"link", and "node".  Does "node" mean "any object or link"?
Or is "node" == "object"?

> 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).

What does "usually come together" mean?


> 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?

If you could be clearer about what you are trying to do, I think
someone here could help.  If you post a little bit of sample code,
you'll get more responses.

## Jason Orendorff    http://www.jorendorff.com/





More information about the Python-list mailing list