Skip to content
Discussion options

You must be logged in to vote

On 32-bit ports that use object representation A (most ports), integers between -230 and 230-1 are "small integers" and are stored directly in the object handle, ie they don't need any heap memory. Integers outside this range are "big integers" and require heap memory (and more memory the larger the value).

Ways around this:

  1. Rebuild the firmware with object representation D. Then floats and integers up to 2**46 do not require heap memory. Downside is that everything runs a bit slower, and everything else uses about 1.5x memory.
  2. Use array('H') and 16-bit numbers only.
  3. Do all the logic that needs 32-bit numbers with @micropython.viper functions.

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@peterhinch
Comment options

@robert-hh
Comment options

@pdw-mb
Comment options

@pdw-mb
Comment options

@jimmo
Comment options

Answer selected by pdw-mb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants