Replies: 1 comment
-
Keeping in might that I have no access to test any of this yet, here's my understanding. If you were to construct an Int object from a scalar or DType.si64 and another Int object from a scalar of DType.si16, both with the exact same scalar value, such that:
if Mojo is handling Int much like Python handles int, which seems to be the goal, then x == y should be True and x is y should also be True, although again I stress that I have no way to test this yet. My reasoning is that in Python the int type is represented internally, as I understand it, using whatever type the Python interpreter determines can most efficiently contain it. Python actually caches small integer objects for efficiency and will re-use them if the same int value is needed. Since Mojo's Int class seems to be meant as a sort of generic integer, I figure they're probably aiming for something similar. Hopefully, somebody who knows for sure will respond to you soon, but since that hasn't happened yet I thought I would give it my best try. DAK Edit --- With regard to your test, I think the assignment "let xp : SI64 = x" in Mojo would function as a case conversion. Perhaps try printing the type of each variable. I also wonder if repr might show something that might not be seen otherwise. |
Beta Was this translation helpful? Give feedback.
-
In my experiments,
Int
seems to be a standard 64-bit signed integer.Obviously, it represents conceptually the same information as a
SIMD[DType.si64, 1]
(also aliased asSI64
).I would expect the two types to be interchangeable, but this is not (currently?) the case, as illustrated by the following code:
Is there any way to extract the information in an
SI64
as anInt
?Beta Was this translation helpful? Give feedback.
All reactions