Big dictionary manipulation

Thomas Güttler guettler at thomas-guettler.de
Mon Jun 16 10:55:21 EDT 2003


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





More information about the Python-list mailing list