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

[stdlib] use __refitem__ in List #2544

Closed
wants to merge 2 commits into from

Conversation

mikowals
Copy link
Contributor

@mikowals mikowals commented May 6, 2024

attempts #2432. Encountered a couple of issues:

For special attention during review, I changed explicit use of __refitem__ in other modules like Dict to just use vanilla foo[index]. I think those calls existed to avoid copies which should be default behaviour with __refitem__ wiring. So var ev = self._entries.__get_ref(index)[] became self.entries[index]. Where specific mutability and lifetimes were being passed I kept the longform use of __refitem__.

@ematejska ematejska added the mojo-repo Tag all issues with this label label May 6, 2024
Signed-off-by: Michael Kowalski <1331470+mikowals@users.noreply.github.com>
Signed-off-by: Michael Kowalski <1331470+mikowals@users.noreply.github.com>
Copy link
Collaborator

@JoeLoser JoeLoser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you! I just asked @Mogball to take a look at #2540 when he gets a chance.

@@ -727,7 +727,7 @@ fn _get_runtime_dtype_size(type: DType) -> Int:
statically known dtypes. Instead, we have to perform a dispatch to
determine the size of the dtype.
"""
alias type_list = List[DType](
alias type_list = StaticTuple[DType, 16](
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion Use InlineArray instead. We're about to mark StaticTuple as deprecated and soon remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InlineArray gets the error: "cannot use a dynamic value in alias initializer". From the line alias concrete_type = type_list[idx]. This is the same error List also gets with the nightly 2024.5.1002. I assume because InlineArray and List make very similar use of __refitem__.

@mikowals
Copy link
Contributor Author

No longer planned as the functionality of __refitem__ is now handled by __getitem__ -> ref [lifetime] T

@mikowals mikowals closed this May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mojo-repo Tag all issues with this label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants