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

[Feature Request] Allow __get_item__ calls to use a mix of colon slices and integers #3081

Open
1 task done
MadAlex1997 opened this issue Jun 19, 2024 · 0 comments
Open
1 task done
Labels
enhancement New feature or request mojo-python-interop mojo-repo Tag all issues with this label

Comments

@MadAlex1997
Copy link

Review Mojo's priorities

What is your request?

With the inclusion of Variant it is now possible to write

fn __getitem__(self, owned *slices: Variant[Slice,Int]) raises -> Self:
    pass

But when you call that method using colon slices, like what is used in Python indexes and works for slice only __get_item__, it gives the error "no matching method in call to 'getitem'".

As I believe this is a parser feature, my request is to add the capability to parse a list of mixed inputs of int and slice (specifically colon slices) into something that can be understood by type checking for *slices: Variant[Slice,Int].

What is your motivation for this change?

This will allow more pythonic indexing of multidimensional arrays, and nested objects. Having to manually create slices using Slice is cumbersome.Pythonic

Any other details?

No response

@MadAlex1997 MadAlex1997 added enhancement New feature or request mojo-repo Tag all issues with this label labels Jun 19, 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 mojo-python-interop mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants