Huge Dicts and perfomance
lucio at movilogic.com
Thu Dec 20 20:47:44 CET 2001
Jason Orendorff wrote:
>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[objectname] = object
>>the  is because i to signify a link betwen obj-a and obj-b, i do:
>>dict[(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[a.name] = a
> dict[(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[(a.name, b.name, c.name)] = LinkObject(a, b, c)
> dict[(a.name, b.name, c.name, d.name)] = LinkObject(a, b, c, d)
>Or is it like this?
> dict[(link1.name, link2.name)] = MetaLinkObject(link1, link2)
> dict[(mlink1.name, mlink2.name)] = MetaMetaLinkObject(mlink1, mlink2)
>Or something else?
Its like this:
dict[(a.name, b.name, c.name)] = LinkObject(a, b, c)
dict[(a.name, b.name, c.name, d.name)] = LinkObject(a, b, c, d)
>>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"?
i have a node, a node can hold objects:
n = node(a,b,c,d)
then i have links betwen nodes:
l = link( node(a,b), node(b,c) )
>>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?
Ok, that was not a good way to phrase my question :)
i start from a node y.
The node has links to other nodes. and links have costs.
i want to know what nodes can be reached spending less than x,. starting
from node y
this algorithm is not the problem, just what representation would you
recoment to hold huge ammounts of data that can allo me to do this.
>>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.
I hope this does not deter the interest in my problem, but i actually
dont know what im doing :)
Im playing with words, texts and dictionaries and toying with python
thanks a lot,
More information about the Python-list