Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Shadowing python built-in function names with warp.func #308

Closed
steinraf opened this issue Sep 5, 2024 · 1 comment
Closed
Assignees
Labels
enhancement New feature or request

Comments

@steinraf
Copy link
Contributor

steinraf commented Sep 5, 2024

Description

Would it be possible to allow shadowing python built-in functions with functions decorated by wp.func?

Context

The following code

import warp as wp


@wp.func
def sum(a: wp.vec3) -> float:
    return a[0] + a[1] + a[2]


@wp.kernel
def k():
    sum(wp.vec3(1.0))


wp.launch(k, [1])

results in ;Could not find function sum as a built-in or user-defined function. Note that user functions must be annotated with a @wp.func decorator to be called from a kernel.

This would not only be useful for sum, but also for other built-in names like abs, filter, hash or others.

Currently this also prohibits function names shadowing built-in constants like Ellipsis or NotImplemented, but this is probably a sane design choice.

@steinraf steinraf added the enhancement New feature or request label Sep 5, 2024
@nvlukasz
Copy link
Contributor

nvlukasz commented Sep 6, 2024

I agree that the current behaviour seems wrong. Python allows shadowing builtins, so we should allow that as well in Warp. I can take a look, thanks for reporting!

@nvlukasz nvlukasz self-assigned this Sep 6, 2024
shi-eric pushed a commit that referenced this issue Sep 9, 2024
Allow shadowing Python builtins

Closes GH-308

See merge request omniverse/warp!722
@steinraf steinraf closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants