Am 30.08.2010 17:53, schrieb Francesco Loffredo:

Two questions and one doubt for you:
1- How many "generations" do you want to keep in a single item (call it
dictionary or list, or record, whatever)? I mean, what if some children
have children too, and some of those have more children, etc ?
There's always one level (generation) of children in an item. An item can have zero or more direct children. And a lot of grandchildren and grandgrandchildren etc. The item-structure represent an assembly hierarchy of the parts of a car. So overall the structure can be up to about 20 levels "deep" and consist of up to 200000 items overall, where the application needs to handle several structures.

2- Are you SURE that there are no circular references in your database?
In your example, what if item_3 was
item_3 = {"id": 3, "name": "child_2", "children_ids": [6, 1, 8]}? Is't
it possible that those recursion limit problems you had could come from
some circular reference in your data?
That's a good hint. But the recursion limit doesn't come from that (the test data actually had no children. I used a single instance of my dict.)

d- If the number of data items is really huge, are you sure that you
want to keep the whole family in memory at the same time? It depends on
the answer you gave to my question #1, of course, but if retrieving an
item from your database is quick as it should be, you could use a query
to resolve the references on demand, and you wouldn't need a special
structure to hold "the rest of the family". If the retrieval is slow or
difficult, then the creation of your structure could take a significant
amount of time.
One thing is, that I have to do some additional calculations when resolving the structure. The items will get some kind of labels/conditions and versions, further, when resolving the structure a set of rules for those conditions is given. At my first shot I'll have to do those calculations in the Python code (even if it would be very wicked to do stuff like that with SQL). So, I will always have a large number of items in memory, as I don't want to call the database for each structure-level I want to expand. Also, I'm using a pyqt-treeview (AbstractItemModel) for a client-site gui. For this purpose I need to create an additional structure, as in the original data items can have more than one parent, which is not permitted in the model for the treeview. The whole idea of replacing the id-references to object-references is to enhance performance and make the application code easier.

Thanks for the feedback so far.

Hope this helps,
Francesco




Nessun virus nel messaggio in uscita.
Controllato da AVG - www.avg.com
Versione: 9.0.851 / Database dei virus: 271.1.1/3100 -  Data di rilascio: 
08/29/10 08:34:00




_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to