Re: [myhdl-list] Signal getattr and setattr
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2010-01-18 08:41:46
|
Christopher L. Felton wrote: > Jan Decaluwe wrote: >> Christopher L. Felton wrote: >>> Jan Decaluwe wrote: >>>> Chris: >>>> >>>> I don't have a lot of time these days (moving to new house) but >>> No problem, this is not a bug often encountered and I have a work around >>> for accessing the "contained" objects attributes/properties. Enjoy >>> moving to the new house! >>> >>>> did your patch mean that __slots__ is the problem? >>> I don't believe __slots__ is the problem. And you do get the >>> performance increase from __slots__ but I don't know how much. >>> >>> I believe the issue is how the copy works. The copy tries to access >>> variables before they exist? I don't know the exact mechanism of the >>> copy but that appears to be the issue. >>> >>> By adding an attribute read in __init__ before it is set, a similar >>> failure occurs. Example first line of __init__ print self._val. >>> >>> At this point two options would be remove __getattr__ or add __copy__ >>> and __deepcopy__ to return a new instance and set attributes manually. >> That seems the good solution. >> >> Of course, how easy it is depends on what "copying" means. The way I >> think about it, it seems trivial: simply create a new signal with the >> same initial value. This would create a new signal that, in the same >> context, would behave identically to the original, but with for the >> rest all separate data structures internally. >> >> That is what a "copy" is to me, but what about your application? > > Yes, copy to me means the same. Same as the copy implementations in > intbv? Adding the __copy__ and __deepcopy__ makes sense otherwise it is > passed to the "val" copy implementation. Then I think the proper way is for the copy functions to return Signal(self._init). -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com Analog design automation: http://www.mephisto-da.com World-class digital design: http://www.easics.com |