bowlerman
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
I do like how Rust does it, but I'm obviously biased as a Rust user.
53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
Sure, but I don't think it should be called
Int
, as though it is the canonical integer type.53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
I'm fine with this. I think that it's better for the ecosystem to settle on 64 bit integers as being the de facto default, though I think that we should require type annotations rather than having a compiler blessed default in
fn
s. I also don't like the Int
naming, but not because I think dynamic integers should be called Int
. Those can be called DynInt
for all I care.53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
I don't think that's good enough for the long term. It seems unnecessary to require the presence of python here.
A
IntLiteral
-> object
cast using PythonObject
could be a workable temporary solution though.53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
Whether the default "integer type" should be arbitrary precision is technically still up for debate, but at least
object
needs to match the python semantics, so there has to be an arbitrary precision integer there somewhere. It's possible to rely on PythonObject
for this, but that means that you need an embedded or external python runtime.53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
That's true. An optimized implementation would want to select integer precision manually, but in that case 64 bits might not always be the right choice either.
53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
It is my understanding that Mojo is not supposed to be reevaluating the semantics of Python, but rather provide ways to easily optimize it.
The perf hit can be mitigated by using tagged enums to avoid requiring indirections for small integers.
53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
Ideally, you could implicitly convert to any of the integer types from
IntLiteral
, which means that doing the optimization would amount to adding a type annotation, which I think fits very nicely with Mojo's philosophy.53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
Not at all. I want an integer type that matches the semantics of the python integer type. I think in python it makes sense mostly for flexibility reasons.
53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
Sure, you can lose a lot of time to cache misses, and selecting algorithms based on precision also costs a bit. It seems like the slowness in Java specifically is not inherent though: https://codeforces.com/blog/entry/17235
Still, because python uses runtime dynamic precision ints by default Mojo should probably do so as well for compatibility and flexibility. Deciding on an appropriate precision is an optimization that can be done when desired.
53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
That's something different from what I'm talking about. You only need a family of types with increasing precision. I'm talking about a single type that can store values of arbitrary precision (perhaps "unbounded dynamic precision" would be a better term). Python doesn't require you to select the precision before running the code.
53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
Of course it's not going to be a blocker. You can probably write an efficient one without inline MLIR as well, but any implementation will take a bit of time.
If there was a way to make a package easily usable by the ecosystem I would just do that instead, but as things are I'm significantly less motivated to build a third party library for something like this than make a PR to the stdlib. Either way I'd like to know which approach makes more sense for Modular.
53 replies
MModular
•Created by bowlerman on 7/2/2024 in #questions
Would you be interested in BigInt support?
Int
is currently not arbitrary precision. It's a pointer width integer (32 or 64 bits). IntLiteral
is arbitrary precision, but cannot be used at runtime.53 replies
MModular
•Created by Mahmoud Hussein on 9/9/2023 in #questions
No dictionaries?
What do you need tuples for that structs can't do? In strict type systems tuples are just anonymous structs with unnamed fields.
12 replies