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 bin()
builtin function
#2603
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, thank you for the contribution! I'd recommend un-drafting this and not coupling it to #2384. We can come back through once #2384 makes it through. Thoughts, @laszlokindrat?
In #2384 I suggested to split up the patch into two: one that delivers |
|
Signed-off-by: Brian Grenier <grenierb96@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thank you!
✅🟣 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. |
Landed in d652195! Thank you for your contribution 🎉 |
[External] [stdlib] Add `bin()` builtin function Fixes #2604 Implements the `bin()` builtin function from Python for converting integral values to a binary string representation. Co-authored-by: bgreni <42788181+bgreni@users.noreply.github.com> Closes #2603 MODULAR_ORIG_COMMIT_REV_ID: 96515ed124867bcac5a49781d57a92fae6bc480b
[External] [stdlib] Add `bin()` builtin function Fixes modularml#2604 Implements the `bin()` builtin function from Python for converting integral values to a binary string representation. Co-authored-by: bgreni <42788181+bgreni@users.noreply.github.com> Closes modularml#2603 MODULAR_ORIG_COMMIT_REV_ID: 96515ed124867bcac5a49781d57a92fae6bc480b
Fixes #2604
Implements the
bin()
builtin function from Python for converting integral values to a binary string representation.Leaving this as a draft for now as Python dictates that any type that implements
__index__
can be passed into this function, and #2384 introduces anIndexer
trait for that method. Which is also blocking theBool
specialization since implementingfn bin(b: Bool)
allowsSIMD
values ofsize > 1
to be implicitly converted.