Skip to content

[REQ] Add support for python @property to warp.struct #1152

@Ghelfi

Description

@Ghelfi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestRequest for something to be added

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions