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

Allow using structs as API #425

Open
almarklein opened this issue Nov 18, 2023 · 0 comments
Open

Allow using structs as API #425

almarklein opened this issue Nov 18, 2023 · 0 comments

Comments

@almarklein
Copy link
Member

We define structs in wgpu.structs, and use them as follows:

  • In the wgpu-native backend, we use it to check incoming dicts.
  • We generate docs off them, that users can use as a reference how to construct their dicts.

But they are not really part of the user-facing API, and (other than flags and enums) they are not injected into the root namespace.

I propose that we make the objects in wgpu.structs callable, so user can type e.g. wgpu.BindGroupEntry( and let autocompletion kick in to show the possible arguments. The call returns a normal Python dict.

In an interactive shell you can also call such an object, get the dict repr-ed in the console, and copy-paste that into your code.

In summary it makes our API a bit more discoverable.

BTW It's probably better to generate these function's code (as opposed to creating the functions dynamically at startup) so that they can be statically discovered and used (easier) by IDE's to show signatures to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant