You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current do_all function rebuilds Python class from C class through parameters. However, the callback function for rebuilding child class only passes child class' fields; it does not pass parent's fields. Consider a simple inheritance Sanajeh-Python program:
classSampleClass:
def__init__(self):
self.x: int=0self.y: int=0defSampleClass(self,seed: int):
random.seed(seed) # this is hardcoded and must existself.x=random.getrandbits(32)%50self.y=random.getrandbits(32)%50classChildClass(SampleClass):
def__init__(self):
super().__init__()
self.color: int=0defChildClass(self,seed: int):
super().SampleClass(seed)
self.color=150# Main functiondefmain(allocator, do_render):
allocator.initialize()
allocator.parallel_new(SampleClass, 1)
allocator.parallel_new(ChildClass, 1)
# do_all functiondefdo_render(tmp):
clr=999ifhasattr(tmp,'color'):
clr=tmp.colorprint("tmp {} {} {}".format(tmp.x,tmp.y,clr))
foriinrange(1):
# for rendering, do allallocator.do_all(SampleClass, do_render)
allocator.do_all(ChildClass, do_render)
The rebuild class in do_all function is defined as:
Current
do_all
function rebuilds Python class from C class through parameters. However, the callback function for rebuilding child class only passes child class' fields; it does not pass parent's fields. Consider a simple inheritance Sanajeh-Python program:The rebuild class in
do_all
function is defined as:while the respective
cdef
C function for rebuilding the class are defined asNotice that the
ChildClass
rebuilding does not take anyx
ory
attributes inherited from its parent.Suggested solution is to change the
cdef
functions as well as the__rebuild
function so that it checks parents' fields and put them too as parameters.The text was updated successfully, but these errors were encountered: