-
Notifications
You must be signed in to change notification settings - Fork 432
Open
Labels
feature requestRequest for something to be addedRequest for something to be added
Description
Description
Similar to standard Python classes, it would be useful to support the @property decorator for warp.struct definitions.
Currently, if a user wants to derive a value from struct members, they must define a separate global warp.func and pass the struct as an argument.
Supporting read-only getters via @property will make the transformation code closer to the struct definition. At the code generation step, these could be lowered to warp.Functions that accept the struct instance as self.
Context
@property is an idiomatic Python feature that is useful for defining class member transformations close to the class definition.
Having this feature would be useful for:
- Keeping derived logic bundled with the data structure rather than scattering helper functions in the global namespace.
- Enabling dot-notation (inst.prop) inside kernels, which is often cleaner than function wrapping (get_prop(inst)).
--
I am happy to provide a PR in this direction to discuss implementation details.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestRequest for something to be addedRequest for something to be added