upvote
It looks very much like some techniques used when minifying JavaScript.
reply
As they say in TDD, write a test, then write the simplest code that will make it pass.

Clearly supporting multiple functions starting with 'p' would be overengineering.

reply
By that standard, this is totally over-engineered. Just hardcode it.
reply
If you are willing to sacrifice performance, you can implement dicts via linear lookup in much less code than a proper hash table.
reply
Because Python dicts guarantee iteration order is the same as insertion order (https://docs.python.org/3.7/library/stdtypes.html#typesmappi...) Python dicts aren’t just proper hash tables.

Because of that it wouldn’t surprise me much if that sped up some standard benchmarks, for example ones parsing lots of small json objects into dictionaries.

reply
It’s Python, you’ve already sacrificed performance, what a little bit more?
reply
That's the spirit!

(Slightly less silly: the folks at https://github.com/faster-cpython are doing great work, too.)

reply
Are they still? I thought this project was no longer really active.
reply
Reminds me of the good 'ol Apple II BASIC. You can name your variables whatever you want, but only the first two letters matter.
reply
Two letters is luxury, when most BASIC interpreters in those days only recognised 1-letter variables.
reply
> Any "w" is a "while"

Meaning that something as simple as "w = 4" would fail? A little too nasty for my liking. Not a choice I would have made, but admire the amount of work done here and the readability of the article. And it's more human-written code than I've done in a number of months!

reply