How are Integers implemented in Mojo?

I experiment with lists of integers in python and mojo and noticed that mojo is way more memory efficient. Is this all done thanks to the static typing or are there other Optimistin methods in play?
2 Replies
ModularBot
ModularBot22h ago
Congrats @fuckAllTechCompanies, you just advanced to level 1!
Darkmatter
Darkmatter21h ago
CPython (the main python implementation), stores integers as an object with an arbitrary width (which is why it will tolerate numbers much larger than 2^64). The extra metadata needed for this has the downsize of meaning it has to be a heap allocation with a size and other metadata, along with the information for python to figure out that the allocation belongs to an integer and not a normal object. Mojo stores 4 or 8 bytes.
Want results from more Discord servers?
Add your server