mojo
mojo copied to clipboard
Introduce stdlib types and methods for dealing with raw bytes
Review Mojo's priorities
- [X] I have read the roadmap and priorities and I believe this request falls within the priorities.
What is your request?
At minimum it would be useful to have a data structure like
struct Bytes:
var data: DynamicVector[UInt8]
Naming is a bikeshed issue.
What is your motivation for this change?
Since the String type will have a small string optimization, there needs to be a way to convert a string to the expected ByteArray representation. Therefore we'd need .to_bytes
on String.
Any other details?
It's worth considering how this type fits in with the generic std list type. It should also probably fit in with the Base64 module.
.to_bytes
is not pythonic. Do you mean str.encode(encoding='utf-8', errors='strict')
?
I just noticed this issue, linking https://github.com/modularml/mojo/pull/2096 for better visibility