Skip to content

Is the parser technology gap between MP and CPython going to pose a serious problem? #8507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RayaneCTX opened this issue Apr 8, 2022 · 2 comments
Labels
py-core Relates to py/ directory in source

Comments

@RayaneCTX
Copy link
Contributor

I feel that MicroPython's desire to keep up with CPython's language features is coming into serious conflict with the fact that CPython's parser technology is superior (PEG parser since Python 3.9). I believe that that fact alone will increasingly and disproportionately contribute to a widening gap between MicroPython and CPython. For example, I have recently been looking at implementing two syntax features: #8479 (function keyword syntax restriction) and #8503 (decorator syntax relaxation), and really, both of these changes should have almost exclusively been grammar changes, and that is quite far from the case. I know these are a lot of moving parts and variables to consider; I just feel that way, and I am willing to believe that the symptoms I am noticing can be solved through cleaner, more modular code rather than a parser overhaul. My concern is as follows: how effectively can we keep up with CPython's syntax features while mitigating the "spaghettification" of our code?

What do you feel? Too early to tell? Chasing ghosts? Or are we indeed sitting on a timed bomb?

For reference, #7847 (comment) discusses a bit why a PEG parser wouldn't be practical for an embedded system.

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Apr 10, 2022
@dpgeorge
Copy link
Member

We have not yet hit any real issues with the current MicroPython parser. It has been working well since day 1. If it were to be changed it would be a big undertaking and a lot of things must be considered, for example code size, heap memory use, C stack use and performance.

At this stage I think it's too early to tell if it needs to be changed to keep up with CPython features. In the end maybe MicroPython doesn't add structural pattern matching or other new syntax features that are too complicated to implement.

@jonnor
Copy link
Contributor

jonnor commented Sep 8, 2024

Seems we are doing OK so far! Specific issues can be opened if/when we hit bottlenecks in terms of parser type.

@jonnor jonnor closed this as completed Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
py-core Relates to py/ directory in source
Projects
None yet
Development

No branches or pull requests

3 participants