Francesc Altet wrote:
> A Monday 24 September 2007, Francesc Altet escrigué:
>> A Monday 24 September 2007, Michael Hoffman escrigué:
>>> Perhaps it would still take the same time over the whole file, but
>>> I think that by doing a depth-first search I can get to the first
>>> Leaf more quickly.
>>>
>>> This is important in two scenarios. First, sometimes I just need to
>>> get a single array, and it doesn't matter which one. Secondly, it
>>> is more reassuring to users (and even myself) to be able to print
>>> progress reports as the file is loading.
>> Mmm, I don't know if I understand you well, but perhaps using a
>> combination of File.getNode and File.{iterNodes, listNodes} (or its
>> Group.{_f_iterNodes, _f_iterNodes} counterparts) could help you avoid
>> reinventing the wheel?

Thanks for the suggestion. This is what I ended up doing:

def walk_nodes(h5file, classname="Array"):
     for group in h5file.root._v_groups.itervalues():
         for node in group._f_walkNodes(classname):
             yield node

> Thinking a bit more into this problem, perhaps you can get the access to 
> node metainfo faster if you create a table with several fields 
> (pathname, node_class and others) and populate it.  Then, for accessing 
> the metainfo you are interested in, you only have to read this table, 
> which is a very fast operation.  Of course, you have to be careful and 
> synchronize the table data with the actual metadata of nodes each time 
> it changes on disk;  however, if your data is mostly read-only then 
> this is not a relevant issue.

I thought about doing this, but I think the performance is acceptable 
with the code I put above which is a bit more convenient than trying to 
maintain my metadata separately.

Thanks again!
-- 
Michael


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to