Live data from Hacker News

MicroPython

micropython.org

101–110 of 152 posts

Re: MicroPython

#101
post #35

There also exists a Python-like language for when you only have a few kb of memory, and can’t even run MicroPython. It’s called “Snek”: https://sneklang.org/

That’s cool. Hadn’t seen that one.

What is a “few kb”? Because last I looked Micropython was like 256kB and the smallest JS interpreter that had foreign function interface was 53kB.

Re: MicroPython

#102
post #14

MicroPython seems to be heavily focused on embedded systems . Is there any support for embedding it within an application , i.e. as a replacement for Lua? Or is there another lightweight Python implementation (or Python-like language) that supports this?

Yes, and this has recently attracted some focus. Take a look at the example for embedding MicroPython:

https://github.com/micropython/micropython/tree/master/examp...

Re: MicroPython

#103

Earlier quoted context omitted.

I was wondering the same as the parent, and in my case it's library support (e.g. NumPy) and compatibility/familiarity in the space (VFX) where Python is everywhere and Lua is unheard of.

If you want NumPy support in particular you basically have to use CPython. The only other implementation that really supports it is PyPy which is not in any sense more lightweight.

Although much smaller in scope than NumPy, MicroPython (and CircuitPython) now have the ulab library which provides similar fast array manipulations:

https://github.com/v923z/micropython-ulab

Re: MicroPython

#104

MicroPython is stellar. If you're building an embedded system for people to hack and customize, make the highest level abstraction of the embedded system in MicroPython so that users can easily modify/patch/contribute/hack your system with ease. This is what Arduino and Arduino IDE did for millions of hobbyist, but it is time to ditch C/C++ for MicroPython. In this [1] PyCon talk by Matt Trentini, a demo of QR code g…

The biggest thing you are underselling (if at all), is that you can have a repl directly into the device itself and doing lots of exploratory programming directly in-circuit.

Re: MicroPython

#105
post #6
post #3

MicroPython is amazing, it runs on very tiny microcontrollers not much else runs on, and makes development of hobbyist embedded projects orders of magnitude easier than C. I backed it way back when, I think for the ESP8266 support, and have loved it ever since.

I wouldn't say "very tiny". For example, does it run (and can do something useful) on a 8 KB cortex M0 with 24 KB of flash?

No, an effective MicroPython environment requires 32KB RAM and a couple of hundred KB of flash (it's possible to use less but the compromises are not worth it IMO).

So yes, it's not possible to use very small devices. Still, this means that MicroPython can run on reasonably small, reasonably cheap devices - and your development effort can be significantly reduced.

Re: MicroPython

#106
post #2

I think this is good for someone getting started with microcontrollers(similar to the Arduino) However, one should not be disillusioned — I doubt this can be used to deploy a mass market product. However, I can see micro-python’s value in rapid-prototyping to some extent for someone who is not into embedded/firmware as much.

In my view, nothing can be used to deploy a product, without further consideration. My rationale for saying this is that in addition to programming in any language, you need to understand hardware, including safety. And I think that by the time a person reaches that level of knowledge, they have probably familiarized themselves with programming at a variety of levels from bare-metal C up to desktop software. Now, I'v…

> one uses a FFT and the other an interrupt running at 170 kHz

Neither of those rule out using MicroPython. Though you are likely to have to do some C work to achieve higher performance.

Re: MicroPython

#107

Neat, but not very practical. To be of any use you still need board support to drive the I2C, SPI, etc which means you have to use C anyhow. You can buy one of their boards with the BSP but that's over $40, yikes. To use micropython you need at least an M4 class micro-controller so that a $5 or greater part. Or you could just stick with C and use a M0 class micro that costs A difference of $40 in BOM cost makes it on…

Going to disagree here, i2c and spi work fine in micropython. Is it as fast as C? No. Does that mean it's useless? No. The absolute coolest thing is to take a $2 Wemos D1 clone, put micropython on it, hook it to a sensor (I've been using temp and humidity sensors lately) and have it periodically fetch " &p= "" rel="nofollow">http://webserver-ip/temp?t= &p= " every 10 seconds and have a little python webserver sitting…

Not only that, but you can live code in the repl on the same device. One can solve a physical problem in less than 15 minutes using these devices.

Re: MicroPython

#108
post #8

> MicroPython implements the entire Python 3.4 syntax Python 3.4 is now over 6 years old. Are there plans to add features from newer Python releases? Or perhaps the developers feel that Python's newer features wouldn't "pull their weight"?

I'd be interested in knowing how much bigger Python has gotten since 3.4 time frame. If course it's not unthinkable that it could always get smaller if there's a lot of refactoring going on, but that might be wishful thinking.

Resource usage is carefully considered when introducing new features; but there are cases where it has becomes smaller. The recent addition of LittleFS meant that a couple of KB more RAM was available at boot for example.

Re: MicroPython

#109

Earlier quoted context omitted.

In my view, nothing can be used to deploy a product, without further consideration. My rationale for saying this is that in addition to programming in any language, you need to understand hardware, including safety. And I think that by the time a person reaches that level of knowledge, they have probably familiarized themselves with programming at a variety of levels from bare-metal C up to desktop software. Now, I'v…

> one uses a FFT and the other an interrupt running at 170 kHz Neither of those rule out using MicroPython. Though you are likely to have to do some C work to achieve higher performance.

Yes, definitely. Any application that I can think of off the top of my head involves adding C code. This is not a hurdle, but would be for someone who is using Python to get into embedded programming at a beginner level. From the MicroPython documentation:

>>>Compiling the cmodule into MicroPython

>>>To build such a module, compile MicroPython (see getting started) with an extra make flag named USER_C_MODULES set to the directory containing all modules you want included (not to the module itself). For example: ...

This is not precisely for the faint of heart, but should not be prohibitive for a seasoned embedded developer. ;-)

Re: MicroPython

#110

MicroPython is stellar. If you're building an embedded system for people to hack and customize, make the highest level abstraction of the embedded system in MicroPython so that users can easily modify/patch/contribute/hack your system with ease. This is what Arduino and Arduino IDE did for millions of hobbyist, but it is time to ditch C/C++ for MicroPython. In this [1] PyCon talk by Matt Trentini, a demo of QR code g…

The biggest thing you are underselling (if at all), is that you can have a repl directly into the device itself and doing lots of exploratory programming directly in-circuit.

This jumps it to the top of my list of tech to explore on microcontrollers.
Post reply on HN