Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: dieter Newsgroups: comp.lang.python Subject: Re: loading trees... Date: Mon, 13 Jun 2016 09:06:24 +0200 Lines: 22 Message-ID: References: <87fush1sb3.fsf@handshake.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.uni-berlin.de meq+63C2vq1Ny+2XL/KkewZ/wLFT874VKM9SDv18smxg== Cancel-Lock: sha1:bE5ClkZINIHcoRo7sNSwAdgAp+U= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'dynamically': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'trees': 0.09; 'python': 0.10; 'code?': 0.16; 'nodes': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'creates': 0.18; 'bit': 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; '(e.g.': 0.27; 'possibility': 0.27; 'directly,': 0.29; 'loads': 0.29; 'allows': 0.30; 'creating': 0.30; 'code': 0.30; 'run': 0.33; 'point': 0.33; 'problem': 0.33; 'file': 0.34; 'this?': 0.34; 'something': 0.35; 'item': 0.35; 'but': 0.36; '(and': 0.36; 'loaded': 0.36; 'structures': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'hi,': 0.38; 'data': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'received:de': 0.40; 'save': 0.60; 'today.': 0.67; 'dict()': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57b397fd.dip0.t-ipconnect.de User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <87fush1sb3.fsf@handshake.de> X-Mailman-Original-References: Xref: csiph.com comp.lang.python:109890 Fillmore writes: > Hi, problem for today. I have a batch file that creates "trees of data". > I can save these trees in the form of python code or serialize them with something > like pickle. > > I then need to run a program that loads the whole forest in the form of a dict() > where each item will point to a dynamically loaded tree. > > What's my best way to achieve this? Pickle? or creating curtom python code? Not sure about the "best". But one possibility would be to use the "ZODB" ("Zope Object DataBase"). The "ZODB" allows you to store rooted graph like data structures (among them forests) persitently. Nodes in this graph are loaded dynamically (and cached). It would be a bit difficult to use Python "dict"s directly, but the ZODB comes with "dict" like data structures which play well with the ZODB persistency (e.g. "BTrees.OOBTree").