From: Maarten S. <maa...@xs...> - 2009-12-18 10:55:02
|
On 18 dec 2009, at 11:43, Francesc Alted wrote: > Hi List, > > I'm about to merge the links branch into trunk, but suddenly it occurred to me > a new idea on how to dereferring soft/external links. Currently, these links > work like this: > > f = tb.openFile('links.h5', 'w') > g = f.createGroup('/', 'g') > a1 = f.createCArray(g, 'a', tb.Int64Atom(), shape=(10000,)) > la = f.createSoftLink('/', 'la', '/g/a') # /la points to /g/a > > and dereferring la is implemented via the `__call__()` method: > > a2 = la() # a2 is the 'a' CArray > > But I think now that perhaps it would be better to implement dereferencing via > a property (say `target`): > > a2 = la.target # a2 is the 'a' CArray > > That would allow to natural naming to work even through links referring to > groups. For example, if lg > > lg = f.createSoftLink('/', 'lg', '/g') # /lg points to /g > > then we could do: > > a3 = f.root.lg.target.a # a3 is the 'a' CArray > > which I think is consistent with the way that PyTables uses to access nodes. > What people think? Hi, Do it in a way that doesn't require me to know if it is a link or not, group or otherwise. Of course when writing you will know, but not when using. I think that means I prefer the first method. In addition you can add a property to manipulate the link itself, but not for normal use of the data. Best, Maarten |