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] Add List[Scalar[D]] append SIMD and Span[Scalar[D]] #3854

Closed

Conversation

martinvuyk
Copy link
Contributor

Add List[Scalar[D]] append SIMD and Span[Scalar[D]]

split off from #3814. This is needed to enable efficient appending of scalar value sequences to a List without having to resort to UnsafePointer manually.

@martinvuyk martinvuyk requested a review from a team as a code owner December 10, 2024 22:54
buffer.append(0)

buffer.append(str_slice.as_bytes())
buffer.append(0) # Add the NUL byte
Copy link
Collaborator

@ConnorGray ConnorGray Dec 11, 2024

Choose a reason for hiding this comment

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

Nice! This is a great cleanup 🙂

In theory this might be slightly less efficient since the append() will need to perform redundant bounds-checking. But I think that's a small cost that we shouldn't worry too much about optimizing yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory this might be slightly less efficient since the append() will need to perform redundant bounds-checking.

We could add a unsafe_no_checks parameter to all the append functions at some point. That way we'd stop having to resort to UnsafePointer so much for such scenarios.

@ConnorGray
Copy link
Collaborator

This is great work Martin 😄 Thanks again for splitting this into its own PR ❤️

Could you add a couple basic tests for the new append(SIMD) and append(Span) overloads? Once this has tests it'll be ready to go 🏎️

Signed-off-by: martinvuyk <[email protected]>
@ConnorGray
Copy link
Collaborator

!sync

@ConnorGray
Copy link
Collaborator

Awesome, thanks for adding those Martin! 🙂 I'll sync this in.

@modularbot modularbot added the imported-internally Signals that a given pull request has been imported internally. label Dec 11, 2024
@ConnorGray
Copy link
Collaborator

!sync

@modularbot
Copy link
Collaborator

✅🟣 This contribution has been merged 🟣✅

Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours.

We use Copybara to merge external contributions, click here to learn more.

@modularbot modularbot added merged-internally Indicates that this pull request has been merged internally merged-externally Merged externally in public mojo repo labels Dec 18, 2024
modularbot added a commit that referenced this pull request Dec 21, 2024
…pan[Scalar[D]]` (#52584)

[External] [stdlib] Add `List[Scalar[D]].extend()` from `SIMD` and
`Span[Scalar[D]]`

Add `List[Scalar[D]].extend()` from `SIMD` and `Span[Scalar[D]]`

Split off from #3814. This is needed to enable efficient
appending of scalar value sequences to a `List` without having to resort
to `UnsafePointer` manually.

ORIGINAL_AUTHOR=martinvuyk
<[email protected]>
PUBLIC_PR_LINK=#3854

Co-authored-by: martinvuyk <[email protected]>
Co-authored-by: Connor Gray <[email protected]>
Closes #3854
MODULAR_ORIG_COMMIT_REV_ID: 7d0c724497ba0671ae660f4de5758d6c4baad7bc
@modularbot
Copy link
Collaborator

Landed in 6eb0b89! Thank you for your contribution 🎉

@modularbot modularbot closed this Dec 21, 2024
msaelices pushed a commit to msaelices/mojo that referenced this pull request Dec 22, 2024
…pan[Scalar[D]]` (#52584)

[External] [stdlib] Add `List[Scalar[D]].extend()` from `SIMD` and
`Span[Scalar[D]]`

Add `List[Scalar[D]].extend()` from `SIMD` and `Span[Scalar[D]]`

Split off from modularml#3814. This is needed to enable efficient
appending of scalar value sequences to a `List` without having to resort
to `UnsafePointer` manually.

ORIGINAL_AUTHOR=martinvuyk
<[email protected]>
PUBLIC_PR_LINK=modularml#3854

Co-authored-by: martinvuyk <[email protected]>
Co-authored-by: Connor Gray <[email protected]>
Closes modularml#3854
MODULAR_ORIG_COMMIT_REV_ID: 7d0c724497ba0671ae660f4de5758d6c4baad7bc
@martinvuyk martinvuyk deleted the add-list-append-simd-and-span branch December 22, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported-internally Signals that a given pull request has been imported internally. merged-externally Merged externally in public mojo repo merged-internally Indicates that this pull request has been merged internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants