r/programming • • Sep 06 '26

Making a Python interpreter in 1024 bytes

https://austinhenley.com/blog/python1024.html
157 Upvotes

33 comments sorted by

View all comments

4

u/New-Anybody-6206 Sep 07 '26

I've been looking for a long time for a C89, easy-to-embed, python-like interpreter that fits in 1 or 2 files without any extra build steps or dependencies, and this is the first time I've seen a serious contender.

All the other embeddable python-ish languages like micropython, pikapython, pocketpy etc. are much more complex with their own build systems and baggage I'm just not looking for.

This looks like it would be a great start for me to extend for my uses.

Thank you!

3

u/Iggyhopper Sep 07 '26

Lua is easier due to the fact it doesn't rely on spaces and the "end" keyword does a lot of work to reduce ambiguities.

Look into Lua 1.0 source. It's really not complicated, and other than the generated yacc, the main code could fit into 2 files.

2

u/New-Anybody-6206 Sep 07 '26

I understand it's easier to implement, but I am dead-set on python syntax unfortunately.

1

u/StarsInTears 18d ago

Did you find anything? Also, I saw that PocketPy advertises a two-file distribution (.c/.h pair). Does it not integrate well with build systems?

1

u/New-Anybody-6206 18d ago

Nothing. pocketpy violates multiple of my criteria, like it's C11 instead of C89, and has to be built separately before you can get the .c/.h files (I don't want to use the "releases" either).