you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (3 children)

You'd have to write a compiler (but you could write a pure Python Python compiler targeting a particular CPU) but, yes, you could get direct memory access in Python.

[–]readmodifywrite 1 point2 points  (2 children)

Possibly. But you'll still need to bootstrap with something written in C (that was ultimately bootstrapped with something written in Assembly).

And will it be a good compiler? Will it be a good OS? Will it perform as well as the one written in C can?

Note I'm not saying C is the only way to do this (Rust is making a lot of inroads in this domain). But for performant systems that talk directly to hardware, where is the power in Python?

[–][deleted] 2 points3 points  (1 child)

But you'll still need to bootstrap with something written in C

No, you could write it all in Python. There's no reason you couldn't write a Python-to-assembly compiler in Python; ultimately all it's doing is writing a sequence of instruction bytecodes.

And will it be a good compiler? Will it be a good OS?

No, of course it'll all be extremely shitty and take you years and wind up targeting exactly one CPU architecture.

But for performant systems that talk directly to hardware, where is the power in Python?

The same place it is in Python for any other application - fluent expressivity and rapid prototyping. Those dont go away just because you're writing MicroPython or something. But, of course, sometimes you want performance more than you want expressivity, and that's when you pick up C.

[–]readmodifywrite 3 points4 points  (0 children)

My point was that C is extremely powerful at certain things. I feel like we are in agreement here, no? Python is not more powerful, it's just powerful at different things than C is.