Description
Right now the file is already quite small (less than 800 lines): https://github.com/lcompilers/lpython/blob/8df052e174adbd789fc7b03f5526e706195b3543/src/runtime/lpython/lpython.py, but every time it has some custom emulation layer, it almost always breaks.
In the past we have already removed two custom layers:
- We emulated UnsignedInteger and it was subtly broken in many cases. We removed it.
goto
: it was emulated and it broke in a new CPython version; we remove dit.
Now there is another breakage regarding pointers and packed structs using numpy arrays (#2267).
We should try to remove as many custom emulation classes as possible, and only use native CPython classes (like we now use "int" to represent unsigned integer). We might need to remove some support for C pointers or pointers in general, because CPython does not have it, and our emulation is too fragile.
Ideally the file should only contain some types, and various conversion functions that can be implemented very robustly and that do not return any "emulated/wrapped" types.
This will make the file much more robust and resilient against future CPython versions.