Big dictionary manipulation

Pawel Lewicki lewy0lewy at NOSPAM_poczta.onet.pl
Mon Jun 16 11:04:00 EDT 2003


Uzytkownik "Thomas Güttler" <guettler at thomas-guettler.de> napisal w
wiadomosci news:bcklp1$k4g7g$1 at ID-63505.news.dfncis.de...
> Pawel Lewicki wrote:
>
> > Hello,
> > I have a question about the strategy of manipulating of big
dictionaries.
> > I build the tree-type dynamic structure of dictionaries. Something like
> > dict={k_1:{k_11:[l_11, l_12]}, k_12:[l_21, l_22], k2:...}
> > Until now I was converting it to the list [k_1, [k_11, [l_11,l_12]]...]
to
> > set and keep the sequence.
> > The final amount of data sometimes is really big and deep so I guess
that
> > conversion is unnecessary waste of time. Maybe I should just add
indexes -
> > lists of keys to iterate.
> > My question is if there is any kind of bottleneck in passing that
> > structure? Is it a reference so no additional memory is consumed?
> > That data would be passed from Zope product to ZPT page if it has any
> > meaning.
>
> Hi Pawel!
>
> Objects are passed by reference in python. You only get problems
> if your structure is bigger than your physical memory. If that's the
> case, you can have a look at BTrees.
>
> Unfortunately it is not clear for me why you convert the dictionary to a
> list.
>
>  thomas

Maybe because I don't now much enough about Python data structures :) I did
it to keep the sequence of iteration, but now I think that adding a list of
sorted keys is much simpler solution.

Pawel






More information about the Python-list mailing list