taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.5k stars 2.28k forks source link

The behavior of property method in the subclass inherited from a data oriented class may need more clarification in document #8580

Open niuiniuin opened 2 months ago

niuiniuin commented 2 months ago

When reading the document for Inheritance of Data-Oriented classes. I simply understand the data-oriented classes have the same behavior of inheritance as ordinary python classes.

However, I find the property method rewritten in the subclass cannot override the property method with the same name in the base class if the base class is decorated with @ti.data_oriented. A simple code can be used for test as below,

import taichi as ti

@ti.data_oriented
class BaseClass(object):
    @property
    def one_property(self):
        return "Property of super-class"
    @ti.kernel
    def compute(self):
        pass
    @ti.func
    def some_function(self):
        pass

class DeviatedClass(BaseClass): 
    @property
    def one_property(self):
        return "Property of sub-class"

a = DeviatedClass()
print(a.one_property)
# output: Property of super-class

where I expect it to output "Property of sub-class". However, it gives the output of "Property of super-class".

I am wondering whether this is a bug or by design. If it is the latter, I think it is essential to explain it in more detail in the document. Since it is a different behavior with ordinary python classes, and may cause very hidden problems in some situations.

alguiguilo098 commented 1 day ago

@niuiniuin hi, i can take this issue, then it's just changing the document you want ?

I'm new to the community, can you send me the environment setup guide and guide contribuity ?