Skip to content
Advertisement

Tag: micropython

Does @staticmethod save any ram in CPython or Micropython?

When answering a recent question I repeated my assumption that one reason for using @staticmethod was to save ram, since a static method was only ever instantised once. This assertion can be found fairly easily online, (e.g. here) and I don’t know where I first encountered it. My reasoning was based on two assumptions, one false: a. that python instantised

Two-Button Menu Iteration

I’ve got a script that I’m adapting to micropython on a 2040, and I want to use two buttons to navigate the menu structure. I can’t figure out how to make the iterate loop in the multi-choice menus work right… here’s what I’ve got so far: In particular, this is the logic I’m wrangling with: Here’s what I’m wanting to

Why does Micropython ‘const’ not accept float values?

Most Micropython ports contain a ‘micropython’ module, which has a specific function called ‘const()’. I am led to believe it behaves a lot like ‘#define’ in C, however, it only accepts integers. Does anyone know why this is? You can declare float constants in C, so why is this unavailable in micropython? I want to efficiently store values which are

Advertisement