tsoding / porth

It's like Forth but in Python
628 stars 50 forks source link

intrinsic map, f-strings, redundant asserts in loops #73

Closed monoidic closed 2 years ago

monoidic commented 2 years ago

This PR moves the intrinsics out of the massive if-else to a separate functions, with a dict mapping intrinsic enums to the functions themselves. I also moved some asserts out of loops where it doesn't make sense to have them (e.g new items aren't going to appear in enums between loop iterations). Some asserts were also made a bit more dynamic. Plus f-strings instead of % formatting. The changes here also provided significant speedup on rule110, from 4.3s to 2.3s or so on Cpython 3.10.

monoidic commented 2 years ago

Huh, should've noticed that some of this is already handled by other PRs.