I would appreciate if I could get some code review. I must say I struggled a bit with the lack of examples in the documentation, and lack of access to the source code to validate some of my concerns (especially, around the random package, as I wanted to know what source it uses).
Consider using String Literal for the alphabet as it is not a dynamic value.
Initialising a string without a String constructor assumes StringLiteral
Also, did you try compiling to .mojopkg?
I usually stub out init.mojo within the subdirs, but does it still work without it? Cause I see you have a global init
Also as far as I understand you initialise an array buffer to 0 but then do a randint fill pass, rendering 0-setting redundant?
Or was the compiler playing nicer?
Consider compiling to mlir representation to observe the internal flow
Also, did you try compiling to .mojopkg?
I usually stub out init .mojo within the subdirs, but does it still work without it? Cause I see you have a global init
I think I got this one wrong! I’m going to fix it.
StringLiteral is a dependent type now so I would avoid using it in this way now. With the recent work on SSO for String there’s also little reason to do so as String will intelligently build a reference to the static data where the default alphabet lives.
randint just repeatedly calls to random_ui64/random_si64. So you can avoid that allocation entirely and just call to random_ui64 directly within you loop