4 ms·
When thinking about a minimal subset of Python to be truly useful, my mind jumps to MicroPython [0]. Which can be compiled to run on a standard platform, inste
by shakna 6y ago
When thinking about a minimal subset of Python to be truly useful, my mind jumps to MicroPython [0].
Which can be compiled to run on a standard platform, instead of the more common baremetal situation.
MicroPython does feature a REPL - though you can disable it so you can control UART in a more expected way.
A surprising amount of plain Python programs can run with the stripped down set.
Even though you won't find any of the referenced functions in sys. However, locals does work, as does builtins. You also get access to pip and a few other unexpected things like that.
[0] https://micropython.org https://micropython.org
- dukoid 6y agoMicroPython is addressing a different problem though: Minimalism wrt. libraries -- opposed to being more "static" in some aspects... In contrast, the author seems to be looking for an "acceptable" core that would still run most libraries -- but omitting some of the more dynamic aspects that are hard to emulate in WebASM....
- pansa2 6y agoNonetheless, MicroPython is more static than CPython. Of the three examples of dynamism in the article (`locals`, `sys.settrace` and `sys._getframe`), MicroPython only supports `locals`.
- stinos 6y agoMicroPython does support sys.settrace
- pansa2 6y agoAh, so it does. I tested this on https://micropython.org/unicorn/ https://micropython.org/unicorn/ and didn't notice that it's running quite an old version.
- shakna 6y agoHowever, it isn't documented [0]. And the sys.settrace tests are allowed to fail: [1] PY_SYS_SETTRACE is a compile time option. It won't necessarily be a part of the build. I don't think it is by default on any of the ports at the moment, though I could be wrong. Based on that, I'd call it an "unstable" part of the implementation at the moment. [0] https://docs.micropython.org/en/latest/library/sys.html https://docs.micropython.org/en/latest/library/sys.html [1] https://github.com/micropython/micropython/blob/master/tests/misc/sys_settrace_generator.py https://github.com/micropython/micropython/blob/master/tests...
- stinos 6y agoFair point about the documentation, but I doubt it's allowed to fail: the 'except AttributeError' is only meant to skip the complete test for builds without support for it, builds which do support it will run the test and will result in a failed build status if the test fails. And yes it's a compile-time option, just like a 100 other features, that's just how it's done in MicroPython and doesn't necessarily equate to 'unstable'.
- shakna 6y agoBeing a compile time option isn't what contributed to the unstable part there - MicroPython is modular. That's part of the benefit of the system. That I couldn't find it enabled on any of the default builds is what made me conclude it might be unstable, especially as it is undocumented.
- stinos 6y agoThe reason for it not being enabled by default is probably twofold: code size increase/performance decrease, and it's not a feature which is used often especially not for the majority of targets.
- ntoll 6y agoMicroPython is an amazing achievement, and Damien has done fantastic work growing the project.